omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Save audio files from speech

    Pythonista
    5
    12
    6166
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Webmaster4o
      Webmaster4o last edited by

      Is there a way to hack the speech module to save audio files instead of directly playing them to the device speakers?

      1 Reply Last reply Reply Quote 0
      • filippocld
        filippocld last edited by

        This post is deleted!
        1 Reply Last reply Reply Quote 0
        • filippocld
          filippocld last edited by

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • Webmaster4o
            Webmaster4o last edited by Webmaster4o

            What did those deleted posts say?

            1 Reply Last reply Reply Quote 0
            • filippocld
              filippocld last edited by

              I misunderstood the problem and posted a script that has nothing to do with saving a file containing a text to speech audio 😊

              1 Reply Last reply Reply Quote 0
              • JonB
                JonB last edited by

                i think this can be done with objc...

                1 Reply Last reply Reply Quote 0
                • filippocld
                  filippocld last edited by

                  Yes. Its easy to make a text to speech. What is difficult is saving the audio data in a file

                  1 Reply Last reply Reply Quote 0
                  • JonB
                    JonB last edited by

                    i was thinking this would be possible with Audio Units, but looking closer, it is not clear that AVSpeechUtterances go through Audio Units.

                    Another possibility is to use one of the various free online tts tools/demos, and download the resulting mp3. This could possibly be done using requests if tou wantthis to be dynamic, or if you are just looking for a sound file for static text, you could just do it manually.

                    1 Reply Last reply Reply Quote 0
                    • Webmaster4o
                      Webmaster4o last edited by

                      That's great news, @JonB. I'll consider this. Is this possible on iOS?

                      1 Reply Last reply Reply Quote 0
                      • omz
                        omz last edited by

                        Unfortunately, the code you linked to is Mac-specific and doesn't work on iOS because the NSSpeechSynthesizer class doesn't exist there. There's only AVSpeechSynthesizer, and from what I can see, it doesn't support any way of saving synthesized speech to disk, apparently not even via private APIs.

                        1 Reply Last reply Reply Quote 0
                        • Webmaster4o
                          Webmaster4o last edited by

                          Ok. Thanks for your help everybody anyway

                          1 Reply Last reply Reply Quote 0
                          • jbap
                            jbap last edited by

                            Look at omz's Audio Recorder.py,
                            https://gist.github.com/omz/9882a00abf59c6009fa4
                            copy and save as audio.py
                            Change lines 63-74 to:

                            if started_recording:
                                import speech, sound
                            	speech.say('Whatever you want it to say')
                                #time.sleep(however many seconds long is the recording)
                                #im not sure if say() is asynchronous, if so, uncomment last line
                            	msg(recorder, None, 'stop')
                            	msg(recorder, None, 'release')
                                #sound.play_effect(os.abspath('Recording.m4a'))
                                #uncomment last line if you want it to play again
                            
                            1 Reply Last reply Reply Quote 1
                            • First post
                              Last post
                            Powered by NodeBB Forums | Contributors