Microsoft Bing Text to Speech library for Python
To install using pip, run the following command:
pip install git+https://github.com/westparkcom/Python-Bing-TTS.git
To install using pipenv, run the following command:
pipenv install git+https://github.com/westparkcom/Python-Bing-TTS.git#egg=bingtts
The following is the usage of the library
translator.speak(text, language, voice, fileformat)
Variable | Description | Note |
---|---|---|
text | The text that you wish to convert to speech | |
language | The language/country you wish to hear the speech in | Case sensitive. See Bing TTS API Reference for list |
voice | The name of the voice to use | Case sensitive |
fileformat | File format to encode the speech to | See Bing TTS API Reference for list of formats |
from bingtts import Translator
translator = Translator('YOUR-API-KEY-HERE')
output = translator.speak("This is a text to speech translation", "en-US", "JessaRUS", "riff-16khz-16bit-mono-pcm")
with open("file.wav", "wb") as f:
f.write(output)