Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -1,11 +1,10 @@
|
|
| 1 |
-
|
| 2 |
from fastapi import FastAPI
|
| 3 |
from pydantic import BaseModel
|
| 4 |
import requests
|
| 5 |
import base64
|
| 6 |
import os
|
| 7 |
|
| 8 |
-
app = FastAPI()
|
| 9 |
|
| 10 |
HUGGINGFACE_API_URL = "https://api-inference.huggingface.co/models/Somali-tts/somali_tts_model"
|
| 11 |
HUGGINGFACE_API_TOKEN = f"Bearer {os.environ['HF_TOKEN']}"
|
|
@@ -20,5 +19,4 @@ def generate_audio(input: TextInput):
|
|
| 20 |
if response.status_code == 200:
|
| 21 |
audio_base64 = base64.b64encode(response.content).decode("utf-8")
|
| 22 |
return {"audio_base64": audio_base64}
|
| 23 |
-
|
| 24 |
-
return {"error": response.json()}
|
|
|
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
from pydantic import BaseModel
|
| 3 |
import requests
|
| 4 |
import base64
|
| 5 |
import os
|
| 6 |
|
| 7 |
+
app = FastAPI() # Waa in lagu magacaabo 'app' si Hugging Face u fahmo
|
| 8 |
|
| 9 |
HUGGINGFACE_API_URL = "https://api-inference.huggingface.co/models/Somali-tts/somali_tts_model"
|
| 10 |
HUGGINGFACE_API_TOKEN = f"Bearer {os.environ['HF_TOKEN']}"
|
|
|
|
| 19 |
if response.status_code == 200:
|
| 20 |
audio_base64 = base64.b64encode(response.content).decode("utf-8")
|
| 21 |
return {"audio_base64": audio_base64}
|
| 22 |
+
return {"error": response.json()}
|
|
|