wip: add tts debug
This commit is contained in:
parent
b71bedb62a
commit
7ce0d89c0c
5 changed files with 3309 additions and 83 deletions
|
|
@ -18,6 +18,10 @@ dependencies = [
|
|||
"pyinstaller>=6.11.0",
|
||||
"twitchwebsocket>=1.2.1",
|
||||
"loguru>=0.7.2",
|
||||
"ffmpeg>=1.4",
|
||||
"ffmpeg-python>=0.2.0",
|
||||
"simpleaudio>=1.0.4",
|
||||
"realtimetts[gtts,minimal,system]>=0.4.17",
|
||||
]
|
||||
|
||||
[tool.uv]
|
||||
|
|
@ -44,7 +48,8 @@ module = [
|
|||
"nltk.tokenize.treebank",
|
||||
"nltk.tokenize.destructive",
|
||||
"TwitchWebsocket",
|
||||
"tokenizer"
|
||||
"tokenizer",
|
||||
"RealtimeTTS"
|
||||
]
|
||||
ignore_missing_imports = true
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ from kivy.uix.widget import Widget
|
|||
|
||||
from src.markovbot_gui.bot_runner import BotRunner
|
||||
from src.markovbot_gui.config_window import ConfigWindow
|
||||
from src.markovbot_gui.tts_window import TTSWindow
|
||||
|
||||
|
||||
class BotApp(App):
|
||||
|
|
@ -51,6 +52,29 @@ class BotApp(App):
|
|||
|
||||
popup.open()
|
||||
|
||||
def run_tts(self, instance):
|
||||
"""Create a TTS window and open it"""
|
||||
tts_window = TTSWindow(config_path=self.config_path)
|
||||
popup = Popup(
|
||||
title=f"TTS configuration, available at {self.config_path}",
|
||||
content=tts_window,
|
||||
size_hint=(None, None),
|
||||
size=(dp(600), dp(400)),
|
||||
auto_dismiss=False,
|
||||
)
|
||||
|
||||
# Add close button
|
||||
close_button = Button(
|
||||
text="Close",
|
||||
size_hint=(None, None),
|
||||
size=(dp(100), dp(40)),
|
||||
pos_hint={"center_x": 0.5},
|
||||
)
|
||||
close_button.bind(on_release=popup.dismiss)
|
||||
tts_window.add_widget(close_button)
|
||||
|
||||
popup.open()
|
||||
|
||||
def build(self):
|
||||
widget = Widget()
|
||||
|
||||
|
|
@ -60,6 +84,10 @@ class BotApp(App):
|
|||
run_button.bind(on_release=self.run_bot)
|
||||
layout.add_widget(run_button)
|
||||
|
||||
tts_button = Button(text="TTS button")
|
||||
tts_button.bind(on_release=self.run_tts)
|
||||
layout.add_widget(tts_button)
|
||||
|
||||
config_button = Button(text="Open config")
|
||||
config_button.bind(on_release=self.run_config)
|
||||
layout.add_widget(config_button)
|
||||
|
|
|
|||
BIN
src/markovbot_gui/output.wav
Normal file
BIN
src/markovbot_gui/output.wav
Normal file
Binary file not shown.
36
src/markovbot_gui/tts_window.py
Normal file
36
src/markovbot_gui/tts_window.py
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
from pathlib import Path
|
||||
|
||||
from kivy.metrics import dp
|
||||
from kivy.uix.boxlayout import BoxLayout
|
||||
from kivy.uix.button import Button
|
||||
from kivy.uix.textinput import TextInput
|
||||
from RealtimeTTS import GTTSEngine, TextToAudioStream
|
||||
|
||||
|
||||
class TTSWindow(BoxLayout):
|
||||
def __init__(self, config_path: Path, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.config_path = config_path
|
||||
self.orientation = "vertical"
|
||||
|
||||
self.spacing = dp(10)
|
||||
self.padding = dp(20)
|
||||
|
||||
# create a text input for the text to be converted to audio,
|
||||
# and a button to execute the conversion
|
||||
|
||||
text_layout = BoxLayout(orientation="vertical")
|
||||
self.add_widget(text_layout)
|
||||
|
||||
self.text_input = TextInput(multiline=True)
|
||||
text_layout.add_widget(self.text_input)
|
||||
|
||||
tts_button = Button(text="TTS button")
|
||||
tts_button.bind(on_release=self.run_tts)
|
||||
text_layout.add_widget(tts_button)
|
||||
|
||||
def run_tts(self, instance):
|
||||
engine = GTTSEngine()
|
||||
stream = TextToAudioStream(engine, language="es")
|
||||
stream.feed(self.text_input.text.strip())
|
||||
stream.play(output_wavfile="output.wav")
|
||||
Loading…
Add table
Add a link
Reference in a new issue