Wrapper for free use Google cloud TTS.
Project description
Voicy
Wrapper for free use Google cloud TTS and STT.
Installation:
Download library using pip
$ pip3 install voicy -U
Getting the token:
For a request to the client need to provide a token. You can easily get it using Token object, or in a browser by yourself.
Both options are described below:
Automated option
- By first, you need to get API token in rucaptcha.
-
After that import a Token object from voicy:
from voicy import Token
-
Then provide the API key to the get_token function:
Token.get_token(rucaptcha_key="Token, that you got in the rucaptcha account.")
- If you do all alright you would get long string, that you should provide to Voice object in init.
Browser option
- By first, go to cloud.google.com/text-to-speech.
-
After that scroll down to the demo part.
- Solve the captcha.
-
After, open the developer console and go to the "Network" section. In column "Name" search for
proxy?url=https://texttospeech.googleapis.com ...
Scroll to the "Query string parameters". And here is your token.
Usage example:
For using TTS you need to provide a dictionary with a key, that is your language code and value – voice model. Format to both you can find in docs.
For using STT you only need to provide a language code. This value is the language of your audio file. Format for the language code you can find in docs.
Simple TTS example:
from voicy import Voicy
voicy = Voicy(token="token")
print(
voicy.tts(
text="You are using a Voicy library. Please, give a star, if you like it.",
voice={"en-US": "en-US-Wavenet-A"},
)
)
This example will return File(path="84PFetz5IJdT4Je.wav", format="wav")
Simple STT example:
from voicy import Voicy
voicy = Voicy(token="token")
print(
voicy.stt(
file="84PFetz5IJdT4Je.wav",
language_code="en-US",
)
)
This example will return Transcript(text="You are using a Voicy library. Please, give a star, if you like it.", confidence=0.93750596, path="84PFetz5IJdT4Je.wav", format="wav")
🤝 Contributing
Feel free to contribute.Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
voicy-0.2.0.2.tar.gz
(6.5 kB
view hashes)