Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,52 +1,31 @@
|
|
| 1 |
-
import
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
"
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
def
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
# Static parameters for generation
|
| 33 |
-
max_tokens = 512
|
| 34 |
-
temperature = 0.7
|
| 35 |
-
top_p = 0.95
|
| 36 |
-
|
| 37 |
-
for token in client.chat_completion(
|
| 38 |
-
messages,
|
| 39 |
-
max_tokens=max_tokens,
|
| 40 |
-
stream=True,
|
| 41 |
-
temperature=temperature,
|
| 42 |
-
top_p=top_p,
|
| 43 |
-
):
|
| 44 |
-
content = token.choices[0].delta.content
|
| 45 |
-
response += content
|
| 46 |
-
yield response
|
| 47 |
-
|
| 48 |
-
# Create the Gradio ChatInterface without additional inputs
|
| 49 |
-
demo = gr.ChatInterface(respond)
|
| 50 |
-
|
| 51 |
-
if __name__ == "__main__":
|
| 52 |
-
demo.launch()
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import tempfile
|
| 3 |
+
|
| 4 |
+
from fastapi import FastAPI
|
| 5 |
+
from fastapi.responses import FileResponse
|
| 6 |
+
|
| 7 |
+
app = FastAPI()
|
| 8 |
+
|
| 9 |
+
MODEL_NAME = "Qwen/Qwen3-TTS-12Hz-0.6B-Base"
|
| 10 |
+
|
| 11 |
+
# Load the model here.
|
| 12 |
+
# Replace this section with the official Qwen code.
|
| 13 |
+
|
| 14 |
+
@app.get("/")
|
| 15 |
+
def health():
|
| 16 |
+
return {"status": "running"}
|
| 17 |
+
|
| 18 |
+
@app.get("/tts")
|
| 19 |
+
def generate(text: str):
|
| 20 |
+
output_file = tempfile.NamedTemporaryFile(
|
| 21 |
+
suffix=".wav",
|
| 22 |
+
delete=False
|
| 23 |
+
).name
|
| 24 |
+
|
| 25 |
+
# Generate audio here.
|
| 26 |
+
|
| 27 |
+
return FileResponse(
|
| 28 |
+
output_file,
|
| 29 |
+
media_type="audio/wav",
|
| 30 |
+
filename="speech.wav",
|
| 31 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|