Spaces:
Edmond98
/
Running on A100

Afrinetwork7 commited on
Commit
fc0645c
1 Parent(s): 1771b70

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -1,5 +1,5 @@
1
  from fastapi import FastAPI, HTTPException
2
- from fastapi.responses import JSONResponse, FileResponse
3
  from pydantic import BaseModel
4
  import numpy as np
5
  import io
@@ -138,13 +138,15 @@ async def synthesize_speech(request: TTSRequest):
138
  buffer.seek(0)
139
  logger.info(f"Buffer size: {buffer.getbuffer().nbytes} bytes")
140
 
141
- logger.info("Preparing FileResponse")
142
- response = FileResponse(
143
- buffer,
144
  media_type="audio/wav",
145
- headers={"Content-Disposition": "attachment; filename=synthesized_audio.wav"}
 
 
146
  )
147
- logger.info("FileResponse prepared successfully")
148
 
149
  return response
150
 
@@ -166,7 +168,7 @@ async def synthesize_speech(request: TTSRequest):
166
  content={"message": "An unexpected error occurred during speech synthesis", "details": error_details}
167
  )
168
  finally:
169
- logger.info("Synthesize request completed")
170
 
171
  @app.post("/identify")
172
  async def identify_language(request: AudioRequest):
 
1
  from fastapi import FastAPI, HTTPException
2
+ from fastapi.responses import JSONResponse, StreamingResponse
3
  from pydantic import BaseModel
4
  import numpy as np
5
  import io
 
138
  buffer.seek(0)
139
  logger.info(f"Buffer size: {buffer.getbuffer().nbytes} bytes")
140
 
141
+ logger.info("Preparing StreamingResponse")
142
+ response = StreamingResponse(
143
+ buffer,
144
  media_type="audio/wav",
145
+ headers={
146
+ "Content-Disposition": "attachment; filename=synthesized_audio.wav"
147
+ }
148
  )
149
+ logger.info("StreamingResponse prepared successfully")
150
 
151
  return response
152
 
 
168
  content={"message": "An unexpected error occurred during speech synthesis", "details": error_details}
169
  )
170
  finally:
171
+ logger.info("Synthesize request completed")
172
 
173
  @app.post("/identify")
174
  async def identify_language(request: AudioRequest):