-
Notifications
You must be signed in to change notification settings - Fork 100
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
Add /upload_sample route to allow upload new speakers using Web API #80
base: main
Are you sure you want to change the base?
Conversation
…d new speakers using API * Added python-multipart to requirements
WalkthroughThe recent update modifies the Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant VersionControl
Developer->>VersionControl: Add modules-xtts.txt to .gitignore
VersionControl-->>Developer: modules-xtts.txt ignored
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 2
Outside diff range and nitpick comments (2)
xtts_api_server/server.py (2)
Line range hint
195-195
: Improve exception handling by using exception chaining.- raise HTTPException(status_code=400, detail=str(e)) + raise HTTPException(status_code=400, detail=str(e)) from eAlso applies to: 204-204, 224-224, 233-233, 298-298, 329-329, 353-353
Tools
Ruff
1-1:
TTS.api.TTS
imported but unused (F401)Remove unused import:
TTS.api.TTS
Line range hint
150-150
: Avoid redefining theget_speakers
function.- @app.get("/speakers") + @app.get("/special_speakers") def get_speakers_special():Tools
Ruff
1-1:
TTS.api.TTS
imported but unused (F401)Remove unused import:
TTS.api.TTS
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- requirements.txt (1 hunks)
- xtts_api_server/server.py (2 hunks)
Files skipped from review due to trivial changes (1)
- requirements.txt
Additional context used
Ruff
xtts_api_server/server.py
1-1:
TTS.api.TTS
imported but unused (F401)Remove unused import:
TTS.api.TTS
10-10:
time
imported but unused (F401)Remove unused import:
time
12-12:
shutil
imported but unused (F401)Remove unused import:
shutil
14-14:
argparse.ArgumentParser
imported but unused (F401)Remove unused import:
argparse.ArgumentParser
15-15: Redefinition of unused
Path
from line 11 (F811)Remove definition:
Path
150-150: Redefinition of unused
get_speakers
from line 145 (F811)
195-195: Within an
except
clause, raise exceptions withraise ... from err
orraise ... from None
to distinguish them from errors in exception handling (B904)
204-204: Within an
except
clause, raise exceptions withraise ... from err
orraise ... from None
to distinguish them from errors in exception handling (B904)
207-207: Do not perform function call
File
in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable (B008)
224-224: Within an
except
clause, raise exceptions withraise ... from err
orraise ... from None
to distinguish them from errors in exception handling (B904)
233-233: Within an
except
clause, raise exceptions withraise ... from err
orraise ... from None
to distinguish them from errors in exception handling (B904)
298-298: Within an
except
clause, raise exceptions withraise ... from err
orraise ... from None
to distinguish them from errors in exception handling (B904)
329-329: Within an
except
clause, raise exceptions withraise ... from err
orraise ... from None
to distinguish them from errors in exception handling (B904)
353-353: Within an
except
clause, raise exceptions withraise ... from err
orraise ... from None
to distinguish them from errors in exception handling (B904)
@@ -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 |
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.
- from TTS.api import TTS
- import time
- import shutil
- from argparse import ArgumentParser
- from pathlib import Path
Committable suggestion was skipped due to low confidence.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using File(...)
as a default argument.
- async def upload_sample(wavFile: UploadFile = File(...)):
+ async def upload_sample(wavFile: UploadFile = None):
+ if wavFile is None:
+ wavFile = File(...)
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
async def upload_sample(wavFile: UploadFile = File(...)): | |
async def upload_sample(wavFile: UploadFile = None): | |
if wavFile is None: | |
wavFile = File(...) |
Tools
Ruff
207-207: Do not perform function call
File
in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable (B008)
Great, thanks, I'll take a look tomorrow. |
Summary by CodeRabbit
New Features
Chores
.gitignore
to excludemodules-xtts.txt
from version control.Dependencies
python-multipart
package to support file uploads.