Skip to content

Commit 44bec19

Browse files
committed
feat(audio): add audio pipeline script
1 parent a297fab commit 44bec19

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

scripts/audio_pipeline.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -137,20 +137,7 @@ def text_to_speech(text, output_filename, task, language_code="en-US", dry_run=F
137137
continue # Move to the next chunk
138138
else:
139139
print(f"Error on chunk {idx + 1}: {e}")
140-
# Implement retry logic or other error handling as needed
141-
retries = 3
142-
for attempt in range(1, retries + 1):
143-
try:
144-
wait_time = 2 ** attempt
145-
print(f"Retrying chunk {idx + 1} in {wait_time} seconds (Attempt {attempt}/{retries})...")
146-
time.sleep(wait_time)
147-
response = client.synthesize_speech(input=synthesis_input, voice=voice, audio_config=audio_config)
148-
break # Success
149-
except Exception as retry_e:
150-
print(f"Retry attempt {attempt} failed for chunk {idx + 1}: {retry_e}")
151-
if attempt == retries:
152-
print(f"Failed to process chunk {idx + 1} after {retries} attempts.")
153-
raise retry_e
140+
raise e
154141

155142
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
156143
tmp_file.write(response.audio_content)
@@ -160,7 +147,6 @@ def text_to_speech(text, output_filename, task, language_code="en-US", dry_run=F
160147
os.remove(temp_filename)
161148
print(f"Chunk {idx + 1}/{len(text_chunks)} processed.")
162149

163-
164150
if audio_segments:
165151
combined = audio_segments[0]
166152
for segment in audio_segments[1:]:

0 commit comments

Comments
 (0)