Update app.py
Browse files
app.py
CHANGED
|
@@ -13,7 +13,7 @@ if HF_TOKEN is None:
|
|
| 13 |
raise ValueError("Environment variable HF_TOKEN not found.")
|
| 14 |
|
| 15 |
client = InferenceClient(
|
| 16 |
-
provider="fal-ai
|
| 17 |
api_key=HF_TOKEN,
|
| 18 |
)
|
| 19 |
|
|
@@ -24,11 +24,14 @@ def tts_generate(text):
|
|
| 24 |
if not text.strip():
|
| 25 |
return None
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
# تبدیل bytes به numpy array و نمونهبرداری
|
| 34 |
buffer = io.BytesIO(audio_bytes)
|
|
|
|
| 13 |
raise ValueError("Environment variable HF_TOKEN not found.")
|
| 14 |
|
| 15 |
client = InferenceClient(
|
| 16 |
+
provider="auto", # میتوانید 'fal-ai' یا 'auto' استفاده کنید
|
| 17 |
api_key=HF_TOKEN,
|
| 18 |
)
|
| 19 |
|
|
|
|
| 24 |
if not text.strip():
|
| 25 |
return None
|
| 26 |
|
| 27 |
+
try:
|
| 28 |
+
# دریافت صوت به صورت bytes
|
| 29 |
+
audio_bytes = client.text_to_speech(
|
| 30 |
+
text,
|
| 31 |
+
model="canopylabs/orpheus-3b-0.1-ft",
|
| 32 |
+
)
|
| 33 |
+
except Exception as e:
|
| 34 |
+
return f"Error: {str(e)}"
|
| 35 |
|
| 36 |
# تبدیل bytes به numpy array و نمونهبرداری
|
| 37 |
buffer = io.BytesIO(audio_bytes)
|