[Question] "Text to Speech" doesn't work When executing the executable file, #3328
Unanswered
jjjunehkim
asked this question in
Q&A
Replies: 1 comment
-
from datetime import datetime
import flet as ft
import pyttsx3
engine = pyttsx3.init()
def say(e, audio, text):
try:
print(text)
file_name = f"tts_{datetime.now().strftime('%Y%m%d%H%M%S')}.wav"
# Create Audio File
engine.save_to_file(text, file_name)
engine.runAndWait()
# Update Audio Controller
audio.src = file_name
audio.update()
audio.play()
except Exception as e:
print(e)
def main(page: ft.Page):
page.vertical_alignment = ft.MainAxisAlignment.CENTER
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
page.window_width = 400
page.window_height = 400
# Initial Audio,
# !!! Must Set on_seek_complete to release the audio !!!
audio = ft.Audio("tts.wav", on_seek_complete=lambda _: audio.release())
page.overlay.append(audio)
input_text = ft.TextField(label="TTS", value="Testing TTS.")
base_column = ft.Column(
controls=[
input_text,
ft.ElevatedButton(
text="Say", on_click=lambda e: say(e, audio, input_text.value)
),
]
)
page.add(
ft.Container(
content=base_column,
)
)
ft.app(target=main, assets_dir="assets") There should be a way to create an audio file with the pyttsx package and play it with ft.Audio. However, when I build using this approach, I get an error about the pywin32 module, so I think I need to use a different tts package. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Question
I used the "flet build windows --include-packages flet_video flet_audio" command to create an executable file that runs the "video", "audio" and "text to speech" functions.
<>
flet build windows --include-packages flet_video flet_audio
<<requirements.txt>>
flet==0.22.*
pyttsx3==2.90
The executable file was created without errors.
But
"Video" -> Work
"Audio" -> Work
"Text to Speech" -> Do not work
I installed "pyttsx3" for "Text to speech".
I understand that "pyttsx3"is a pure library.
So I thought the executable file would operate normally,
But it does not.
Please help for some reason.
Code sample
No response
Error message
No response
------------------------------------------------------
Beta Was this translation helpful? Give feedback.
All reactions