Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,7 @@ import scipy.io.wavfile
|
|
| 7 |
from fastapi import FastAPI, UploadFile, File, HTTPException
|
| 8 |
from fastapi.responses import StreamingResponse
|
| 9 |
from fastapi.responses import FileResponse
|
|
|
|
| 10 |
from pydantic import BaseModel
|
| 11 |
from faster_whisper import WhisperModel
|
| 12 |
from transformers import VitsModel, AutoTokenizer
|
|
@@ -111,15 +112,18 @@ async def text_to_speech(request: TTSRequest):
|
|
| 111 |
# Get the bytes and manually ensure the buffer is ready
|
| 112 |
content = buffer.getvalue()
|
| 113 |
buffer.close()
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
|
|
|
| 117 |
media_type="audio/wav",
|
| 118 |
headers={
|
| 119 |
-
"Content-Disposition": "
|
| 120 |
-
"Content-Length": str(len(content))
|
|
|
|
| 121 |
}
|
| 122 |
)
|
|
|
|
| 123 |
|
| 124 |
@app.get("/health")
|
| 125 |
def health():
|
|
|
|
| 7 |
from fastapi import FastAPI, UploadFile, File, HTTPException
|
| 8 |
from fastapi.responses import StreamingResponse
|
| 9 |
from fastapi.responses import FileResponse
|
| 10 |
+
from fastapi import Response
|
| 11 |
from pydantic import BaseModel
|
| 12 |
from faster_whisper import WhisperModel
|
| 13 |
from transformers import VitsModel, AutoTokenizer
|
|
|
|
| 112 |
# Get the bytes and manually ensure the buffer is ready
|
| 113 |
content = buffer.getvalue()
|
| 114 |
buffer.close()
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
return Response(
|
| 118 |
+
content=content,
|
| 119 |
media_type="audio/wav",
|
| 120 |
headers={
|
| 121 |
+
"Content-Disposition": "attachment; filename=speech.wav",
|
| 122 |
+
"Content-Length": str(len(content)),
|
| 123 |
+
"Access-Control-Expose-Headers": "Content-Disposition" # Crucial for CORS/Proxy
|
| 124 |
}
|
| 125 |
)
|
| 126 |
+
|
| 127 |
|
| 128 |
@app.get("/health")
|
| 129 |
def health():
|