Skip to main content

Wrapper for free use Google cloud TTS.

Project description

Voicy

Wrapper for free use TTS & STT services.

Installation:

Download library using pip
$ pip3 install voicy -U

Usage example:

Google Cloud

For a request to the Google Cloud client, you need to provide a token. You can easily get it using GoogleToken object, or in a browser by yourself.

Both options are described below:

Automated option
  1. By first, you need to get API key in rucaptcha.
  2. After that import a GoogleToken object from voicy:
    from voicy import GoogleToken
  3. Then provide the API key to the get_token function:
    GoogleToken.get_token(rucaptcha_key="Key, that you got in the rucaptcha account.")
  4. If you do all alright you would get long string, that you should provide to Google 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". That long string is your token. Provide it to Google object in init.

For using TTS you need to provide a dictionary where the key is your language code and the value is your voice model. Format to both you can find in docs. Also, if you don't want to get a token you can use a TTS from Google Translate.

Simple TTS example:
from voicy import Google

google = Google(token="token")

print(
    google.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:

For using STT you only need to provide a language code. Format for it you can find in docs.

from voicy import Google

google = Google(token="token")

print(
    google.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")

Yandex Cloud:

For using Yandex TTS you don't need to provide any token. Just pass text, language code and voice model:

from voicy import Yandex

yandex = Yandex()

print(
    yandex.tts(
        text="You are using a Voicy library. Please, give a star, if you like it.",
        language_code="en-US",
        voice="ermil",
    )
)
This example will return File(path="SUypGpSLTvGKTTy.wav", format="wav")

License

The library is under the GNU LGPLv3 license.

BE AWARE THAT THE AUTHORS ARE UNDER NO CIRCUMSTANCES RESPONSIBLE FOR CONSEQUENCES OF USE AND ANY INTERACTION WITH THE LIBRARY. NOT LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. THE CODE IS PROVIDED FOR EDUCATION PURPOSES ONLY.

Read the LICENSE for more information.

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.4.2.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

voicy-0.4.2-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file voicy-0.4.2.tar.gz.

File metadata

  • Download URL: voicy-0.4.2.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for voicy-0.4.2.tar.gz
Algorithm Hash digest
SHA256 e9884be5018d907284e8460228f836cf382ced1c387453884ea4f2736c48936a
MD5 ab4f50e9f75c6c17bc3f80771755adfd
BLAKE2b-256 858b4bce0a85231c9d86b7cf6e4ddab5db30b252a08f729d592077bf7aa7a7fb

See more details on using hashes here.

File details

Details for the file voicy-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: voicy-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for voicy-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1aae214924232b82c53c6971a255eebd7fad10cafb300a6592d1edcdff14d9e9
MD5 66a76ea390f2846523d1936cd6c1265b
BLAKE2b-256 6c3656fc892b3147cbecc922286c07edef07c07f089695bf734b9124fc57fa68

See more details on using hashes here.

Supported by

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