Spaces:
Runtime error
Runtime error
Update utils.py
Browse files
utils.py
CHANGED
|
@@ -8,8 +8,6 @@ import re
|
|
| 8 |
import tempfile
|
| 9 |
import requests
|
| 10 |
from bs4 import BeautifulSoup
|
| 11 |
-
from pydub import AudioSegment
|
| 12 |
-
import io
|
| 13 |
|
| 14 |
groq_client = Groq(api_key=os.environ["GROQ_API_KEY"])
|
| 15 |
tokenizer = tiktoken.get_encoding("cl100k_base")
|
|
@@ -104,9 +102,7 @@ def generate_audio(text: str, speaker: str) -> str:
|
|
| 104 |
if response.status_code != 200:
|
| 105 |
raise Exception(f"Error generating audio: {response.text}")
|
| 106 |
|
| 107 |
-
#
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as temp_audio:
|
| 111 |
-
audio.export(temp_audio.name, format="wav")
|
| 112 |
return temp_audio.name
|
|
|
|
| 8 |
import tempfile
|
| 9 |
import requests
|
| 10 |
from bs4 import BeautifulSoup
|
|
|
|
|
|
|
| 11 |
|
| 12 |
groq_client = Groq(api_key=os.environ["GROQ_API_KEY"])
|
| 13 |
tokenizer = tiktoken.get_encoding("cl100k_base")
|
|
|
|
| 102 |
if response.status_code != 200:
|
| 103 |
raise Exception(f"Error generating audio: {response.text}")
|
| 104 |
|
| 105 |
+
# Save the raw audio data
|
| 106 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as temp_audio:
|
| 107 |
+
temp_audio.write(response.content)
|
|
|
|
|
|
|
| 108 |
return temp_audio.name
|