A
A
Alex_Kuzen2021-10-26 22:07:30
Python
Alex_Kuzen, 2021-10-26 22:07:30

Why does gTTS give an error in Kivy?

from  kivy.app import  App
from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.progressbar import ProgressBar
from kivy.graphics.transformation import Matrix
from kivy.animation import Animation
from gtts import gTTS





class Container(BoxLayout):

    def Converting(self):
        One = str(self.text_1.text)
        Two = str(self.text_2.text)
        tts1 = gTTS(One)
        tts2 = gTTS(Two)
        final_tts = (tts1, tts2)
        tts1.save('Hello.mp3')





class MyApp(App):
    def build(self):
        return Container()


if __name__ == "__main__":
    MyApp().run()


And Qiwi code

<Container>:

    button:Convert_Button
    text_1: Text_Input_1
    text_2: Text_Input_2
    text_3: Text_Input_3
    BoxLayout:

        Button:
`
            font_size: 20
            size_hint: 1, 0.1
            pos_hint: {'center.x':1, 'y': 0}
            id: Convert_Button
            text: 'Конвертирование'
            on_release:
                root.Converting()


        TextInput:

            size_hint: 0.1, 0.1
            pos_hint: {'center.x':-1, 'center.y':1}
            id: Text_Input_1


        TextInput:

            size_hint: 0.1, 0.1
            pos_hint: {'x':-1, 'center.y':-1 }
            id: Text_Input_2

        TextInput:

            size_hint: 0.3, 0.2
            pos_hint: {'x':-1, 'center.y':-1 }
            id: Text_Input_3


There are 2 problems 1. the
window crashes when I try to save an mp3 from the written text.
2. Even if you take gTTS out of the function and try to make it work even just at the moment of running the code, it creates just an empty mp3 file without saving anything to it.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question