Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -549,26 +549,14 @@ async def text_to_speech_v2(request: AudioAPI.TTSRequest, api_key: str = Depends
|
|
549 |
model=request.model,
|
550 |
voice=request.voice,
|
551 |
input=request.input,
|
552 |
-
response_format=
|
553 |
)
|
554 |
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
raise HTTPException(status_code=500, detail=str(e))
|
559 |
-
# try:
|
560 |
-
# response = openai_client.audio.speech.create(
|
561 |
-
# model=request.model,
|
562 |
-
# voice=request.voice,
|
563 |
-
# input=request.input,
|
564 |
-
# response_format=request.output_format
|
565 |
-
# )
|
566 |
-
|
567 |
-
# content_type = f"audio/{request.output_format.value}"
|
568 |
-
# if request.output_format == OpenaiTTSModels.OutputFormat.pcm:
|
569 |
-
# content_type = "audio/pcm"
|
570 |
|
571 |
-
|
572 |
|
573 |
except Exception as e:
|
574 |
raise HTTPException(status_code=500, detail=str(e))
|
|
|
549 |
model=request.model,
|
550 |
voice=request.voice,
|
551 |
input=request.input,
|
552 |
+
response_format=request.output_format
|
553 |
)
|
554 |
|
555 |
+
content_type = f"audio/{request.output_format.value}"
|
556 |
+
if request.output_format == OpenaiTTSModels.OutputFormat.pcm:
|
557 |
+
content_type = "audio/pcm"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
558 |
|
559 |
+
return StreamingResponse(io.BytesIO(response.content), media_type=content_type)
|
560 |
|
561 |
except Exception as e:
|
562 |
raise HTTPException(status_code=500, detail=str(e))
|