-
Notifications
You must be signed in to change notification settings - Fork 146
Add /upload_sample route to allow upload new speakers using Web API #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
98845ca
9f783f6
1e7a025
47d3568
571c4f2
f10207f
5e310e0
65dfd1c
f720b33
0e9f827
e7faea6
c9e67cf
f1e8c39
c388e1d
38f8dfa
2570806
dd9c688
19a1f69
c5de028
1d412ea
5c1a35f
241dd37
ae57177
bf46de0
f51038b
0218c48
b8a1ca0
05b5812
5cf3f7e
33efb27
8164e94
6f08109
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,5 @@ | ||||||||||
| from TTS.api import TTS | ||||||||||
| from fastapi import BackgroundTasks, FastAPI, HTTPException, Request, Query | ||||||||||
| from fastapi import BackgroundTasks, FastAPI, HTTPException, Request, Query, File, UploadFile | ||||||||||
| from fastapi.middleware.cors import CORSMiddleware | ||||||||||
| from fastapi.responses import FileResponse,StreamingResponse | ||||||||||
|
|
||||||||||
|
|
@@ -203,6 +203,17 @@ def set_speaker_folder(speaker_req: SpeakerFolderRequest): | |||||||||
| logger.error(e) | ||||||||||
| raise HTTPException(status_code=400, detail=str(e)) | ||||||||||
|
|
||||||||||
| @app.post("/upload_sample") | ||||||||||
| async def upload_sample(wavFile: UploadFile = File(...)): | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid using - async def upload_sample(wavFile: UploadFile = File(...)):
+ async def upload_sample(wavFile: UploadFile = None):
+ if wavFile is None:
+ wavFile = File(...)Committable suggestion
Suggested change
ToolsRuff
|
||||||||||
|
|
||||||||||
| UPLOAD_DIR = XTTS.speaker_folder | ||||||||||
| os.makedirs(UPLOAD_DIR, exist_ok=True) | ||||||||||
| file_path = os.path.join(UPLOAD_DIR, wavFile.filename) | ||||||||||
| with open(file_path, "wb") as file_object: | ||||||||||
| file_object.write(await wavFile.read()) | ||||||||||
| return {"filename": wavFile.filename} | ||||||||||
|
|
||||||||||
|
|
||||||||||
| @app.post("/switch_model") | ||||||||||
| def switch_model(modelReq: ModelNameRequest): | ||||||||||
| try: | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unused imports to clean up the code.