Spaces:
Running
Running
jonathanagustin
commited on
Commit
•
bcc0594
1
Parent(s):
b990bac
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
@@ -51,12 +51,12 @@ def tts(
|
|
51 |
response_format=response_format,
|
52 |
speed=speed,
|
53 |
)
|
54 |
-
|
|
|
55 |
file_extension = f".{response_format}"
|
56 |
with tempfile.NamedTemporaryFile(suffix=file_extension, delete=False) as temp_file:
|
57 |
temp_file_path = temp_file.name
|
58 |
|
59 |
-
# Use with_streaming_response() as suggested
|
60 |
with response.with_streaming_response():
|
61 |
for chunk in response:
|
62 |
temp_file.write(chunk)
|
@@ -85,7 +85,7 @@ def main():
|
|
85 |
for voice in VOICE_OPTIONS
|
86 |
}
|
87 |
|
88 |
-
# Download audio previews
|
89 |
PREVIEW_DIR = "voice_previews"
|
90 |
os.makedirs(PREVIEW_DIR, exist_ok=True)
|
91 |
|
|
|
51 |
response_format=response_format,
|
52 |
speed=speed,
|
53 |
)
|
54 |
+
|
55 |
+
# Save the audio content to a temporary file
|
56 |
file_extension = f".{response_format}"
|
57 |
with tempfile.NamedTemporaryFile(suffix=file_extension, delete=False) as temp_file:
|
58 |
temp_file_path = temp_file.name
|
59 |
|
|
|
60 |
with response.with_streaming_response():
|
61 |
for chunk in response:
|
62 |
temp_file.write(chunk)
|
|
|
85 |
for voice in VOICE_OPTIONS
|
86 |
}
|
87 |
|
88 |
+
# Download audio previews before initiating the interface
|
89 |
PREVIEW_DIR = "voice_previews"
|
90 |
os.makedirs(PREVIEW_DIR, exist_ok=True)
|
91 |
|