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
-
This post is deleted! -
What did those deleted posts say?
-
I misunderstood the problem and posted a script that has nothing to do with saving a file containing a text to speech audio 😊
-
i think this can be done with objc...
-
Yes. Its easy to make a text to speech. What is difficult is saving the audio data in a file
-
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. -
-
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 onlyAVSpeechSynthesizer
, and from what I can see, it doesn't support any way of saving synthesized speech to disk, apparently not even via private APIs. -
Ok. Thanks for your help everybody anyway
-
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