Hey there, Iโm creating a streamlit application which requires TTS in it.
`
def speak_text(text, voice, rate=150):
engine = pyttsx3.init()
print("TEXT : ", text, '\n')
print("VOICE : ", voice, '\n')
st.write("VOICE : " , voice)
engine.setProperty('voice', voice)
engine.setProperty('rate', rate)
download_dir = 'dir_mp3'
os.makedirs(download_dir, exist_ok=True)
file_path = os.path.join(download_dir, "my_audio.wav")
engine.save_to_file(text, file_path)
# time.sleep(2)
engine.runAndWait()
engine.stop()
return file_path
The above code mentioned is working properly as desired in my local environment but during deployment I get file not found(my_audio.wav) error seems like file isnโt getting created inside the function and โfile_pathโ contains a path which doesnโt exist.
Any idea why so ?
Link to my code