Skip to main content

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
  1. By first, you need to get API token in rucaptcha.
  2. After that import a Token object from voicy:
    from voicy import Token
  3. Then provide the API key to the get_token function:
    Token.get_token(rucaptcha_key="Token, that you got in the rucaptcha account.")
  4. If you do all alright you would get long string, that you should provide to Voice object in init.
Browser option
  1. By first, go to cloud.google.com/text-to-speech.
  2. After that scroll down to the demo part.
    Recaptcha
  3. Solve the captcha.
  4. After, open the developer console and go to the "Network" section. In column "Name" search for proxy?url=https://texttospeech.googleapis.com ...
    The developer console
    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


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.1.tar.gz (6.5 kB view hashes)

Uploaded Source

Built Distribution

voicy-0.2.0.1-py3-none-any.whl (8.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page