Swift: How to Convert Text-to-Speech Generated Audio to .mp3?

前端 未结 1 942
轮回少年
轮回少年 2021-01-19 09:19

I have converted text to speech using the AVSpeechSynthesizer. When clicked on Play, converted speech plays. I don\'t know the extension of this audio file.

相关标签:
1条回答
  • 2021-01-19 09:59

    A simple strategy would be saving your output from AVSpeechSynthesizer to a directory first, then changing its format.
    But, as far as I know AVSpeechSynthesizer does not let you save your outputs. I would suggest you to check the following post: Save audio stream to mp3 file (iOS)
    Quoting from IanStallings:

    Unfortunately no, there is no public API available to capture the speaker output and looking over the docs for AVSpeechSynthesizer and related classes I don't see a way to capture any audio from it. You may want to look at 3rd party libraries to help with this.

    And another one: AVSpeechSynthesizer output as file?
    Again, quoting from Bhumit Mehta:

    As of now AVSpeechSynthesizer does not support this . There in no way get the audio file using AVSpeechSynthesizer . I tried this few weeks ago for one of my apps and found out that it is not possible , Also nothing has changed for AVSpeechSynthesizer in iOS 8.

    0 讨论(0)
提交回复
热议问题