pvanand commited on
Commit
775f284
1 Parent(s): 04addc9

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +5 -17
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="mp3" # Always set to MP3
553
  )
554
 
555
- return StreamingResponse(io.BytesIO(response.content), media_type="audio/mp3")
556
-
557
- except Exception as e:
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
- # return StreamingResponse(io.BytesIO(response.content), media_type=content_type)
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))