File tree Expand file tree Collapse file tree 2 files changed +31
-5
lines changed
Expand file tree Collapse file tree 2 files changed +31
-5
lines changed Original file line number Diff line number Diff line change @@ -224,10 +224,13 @@ async def dual_output():
224224 ).decode ("utf-8" )
225225
226226 # Add any chunks that may be in the acumulator into the return word_timestamps
227- chunk_data .word_timestamps = (
228- timestamp_acumulator + chunk_data .word_timestamps
229- )
230- timestamp_acumulator = []
227+ if chunk_data .word_timestamps is not None :
228+ chunk_data .word_timestamps = (
229+ timestamp_acumulator + chunk_data .word_timestamps
230+ )
231+ timestamp_acumulator = []
232+ else :
233+ chunk_data .word_timestamps = []
231234
232235 yield CaptionedSpeechResponse (
233236 audio = base64_chunk ,
@@ -272,7 +275,7 @@ async def single_output():
272275 )
273276
274277 # Add any chunks that may be in the acumulator into the return word_timestamps
275- if chunk_data .word_timestamps != None :
278+ if chunk_data .word_timestamps is not None :
276279 chunk_data .word_timestamps = (
277280 timestamp_acumulator + chunk_data .word_timestamps
278281 )
Original file line number Diff line number Diff line change 1+ import base64
2+ import json
3+
4+ import pydub
5+ import requests
6+
7+ def generate_audio_from_phonemes (phonemes : str , voice : str = "af_bella" ):
8+ """Generate audio from phonemes"""
9+ response = requests .post (
10+ "http://localhost:8880/dev/generate_from_phonemes" ,
11+ json = {"phonemes" : phonemes , "voice" : voice },
12+ headers = {"Accept" : "audio/wav" }
13+ )
14+ if response .status_code != 200 :
15+ print (f"Error: { response .text } " )
16+ return None
17+ return response .content
18+
19+
20+
21+
22+ with open (f"outputnostreammoney.wav" , "wb" ) as f :
23+ f .write (generate_audio_from_phonemes (r"mɪsəki ɪz ɐn ɪkspˌɛɹəmˈɛntᵊl ʤˈitəpˈi ˈɛnʤən dəzˈInd tə pˈWəɹ fjˈuʧəɹ vˈɜɹʒənz ʌv kəkˈɔɹO mˈɑdᵊlz." ))
You can’t perform that action at this time.
0 commit comments