Spaces:
Running
Running
Commit ·
5ba53f6
1
Parent(s): fbf425d
v0.1 debug
Browse files
app.py
CHANGED
|
@@ -7,7 +7,7 @@ import tempfile
|
|
| 7 |
from fastapi.responses import FileResponse
|
| 8 |
|
| 9 |
|
| 10 |
-
#curl -
|
| 11 |
|
| 12 |
|
| 13 |
# Charger le modèle TTS
|
|
@@ -17,6 +17,13 @@ tts = TTS(MODEL_NAME)
|
|
| 17 |
# Initialiser l'application FastAPI
|
| 18 |
app = FastAPI()
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
class TextInput(BaseModel):
|
| 21 |
text: str
|
| 22 |
|
|
@@ -27,12 +34,19 @@ def generate_tts(input: TextInput):
|
|
| 27 |
raise HTTPException(status_code=400, detail="Le texte ne peut pas être vide.")
|
| 28 |
|
| 29 |
try:
|
|
|
|
|
|
|
| 30 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmpfile:
|
| 31 |
output_path = tmpfile.name
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
# Générer l'audio
|
| 34 |
tts.tts_to_file(text=input.text, file_path=output_path)
|
| 35 |
|
|
|
|
|
|
|
| 36 |
return FileResponse(output_path, media_type="audio/wav", filename="output.wav")
|
| 37 |
except Exception as e:
|
| 38 |
raise HTTPException(status_code=500, detail=str(e))
|
|
|
|
| 7 |
from fastapi.responses import FileResponse
|
| 8 |
|
| 9 |
|
| 10 |
+
#curl -X POST -H "Content-Type: application/json" -d '{"message": "Hello ! How are you ?"}' https://micksoftware-vctk.hf.space/tts
|
| 11 |
|
| 12 |
|
| 13 |
# Charger le modèle TTS
|
|
|
|
| 17 |
# Initialiser l'application FastAPI
|
| 18 |
app = FastAPI()
|
| 19 |
|
| 20 |
+
print("Test du modèle TTS...")
|
| 21 |
+
try:
|
| 22 |
+
tts.tts_to_file(text="Test audio", file_path="test.wav")
|
| 23 |
+
print("Le modèle fonctionne correctement.")
|
| 24 |
+
except Exception as e:
|
| 25 |
+
print("Erreur lors du test du modèle :", e)
|
| 26 |
+
|
| 27 |
class TextInput(BaseModel):
|
| 28 |
text: str
|
| 29 |
|
|
|
|
| 34 |
raise HTTPException(status_code=400, detail="Le texte ne peut pas être vide.")
|
| 35 |
|
| 36 |
try:
|
| 37 |
+
print("generation starts", input.text.strip())
|
| 38 |
+
|
| 39 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmpfile:
|
| 40 |
output_path = tmpfile.name
|
| 41 |
+
|
| 42 |
+
print("tmp file ready")
|
| 43 |
+
|
| 44 |
|
| 45 |
# Générer l'audio
|
| 46 |
tts.tts_to_file(text=input.text, file_path=output_path)
|
| 47 |
|
| 48 |
+
print("tmp file generated")
|
| 49 |
+
|
| 50 |
return FileResponse(output_path, media_type="audio/wav", filename="output.wav")
|
| 51 |
except Exception as e:
|
| 52 |
raise HTTPException(status_code=500, detail=str(e))
|