Skip to main content

A simple text-to-speech client using azure TTS API(trial).

Project description

:speaking_head: aspeak

GitHub stars GitHub issues GitHub forks GitHub license PyPI version

A simple text-to-speech client using azure TTS API(trial). :laughing:

TL;DR: This program uses trial auth token of Azure Cognitive Services to do speech synthesis for you.

You can try the Azure TTS API online: https://azure.microsoft.com/en-us/services/cognitive-services/text-to-speech

Installation

$ pip install --upgrade aspeak

Usage

usage: aspeak [-h] [-V | -L | [-t [TEXT] | -s [SSML]]] [-p PITCH] [-r RATE] [-S STYLE] [-f FILE] [-e ENCODING] [-o OUTPUT_PATH] [-l LOCALE] [-v VOICE]

This program uses trial auth token of Azure Cognitive Services to do speech synthesis for you

options:
  -h, --help            show this help message and exit
  -V, --version         show program's version number and exit
  -L, --list-voices     list available voices, you can combine this argument with -v and -l
  -t [TEXT], --text [TEXT]
                        Text to speak. Left blank when reading from file/stdin
  -s [SSML], --ssml [SSML]
                        SSML to speak. Left blank when reading from file/stdin
  -f FILE, --file FILE  Text/SSML file to speak, default to `-`(stdin)
  -e ENCODING, --encoding ENCODING
                        Text/SSML file encoding, default to "utf-8"
  -o OUTPUT_PATH, --output OUTPUT_PATH
                        Output wav file path
  -l LOCALE, --locale LOCALE
                        Locale to use, default to en-US
  -v VOICE, --voice VOICE
                        Voice to use

Options for --text:
  -p PITCH, --pitch PITCH
                        Set pitch, default to 0
  -r RATE, --rate RATE  Set speech rate, default to 0.04
  -S STYLE, --style STYLE
                        Set speech style, default to "general"
  • If you don't specify -o, we will use your default speaker.
  • If you don't specify -t or -s, we will assume -t is provided.
  • You must specify voice if you want to use -p or -r option.

Examples

Speak "Hello, world!" to default speaker.

$ aspeak -t "Hello, world!"

List all available voices.

$ aspeak -L

List all available voices for Chinese.

$ aspeak -L -l zh-CN

Get information about a voice.

$ aspeak -L -v en-US-SaraNeural
Output
Microsoft Server Speech Text to Speech Voice (en-US, SaraNeural)
Display Name: Sara
Local Name: Sara @ en-US
Locale: English (United States)
Gender: Female
ID: en-US-SaraNeural
Styles: ['cheerful', 'angry', 'sad']
Voice Type: Neural
Status: GA

Save synthesized speech to a file.

$ aspeak -t "Hello, world!" -o output.wav

Read text from file and speak it.

$ cat input.txt | aspeak

or

$ aspeak -f input.txt

with custom encoding:

$ aspeak -f input.txt -e gbk

Read from stdin and speak it.

$ aspeak

or (more verbose)

$ aspeak -f -

maybe you prefer:

$ aspeak -l zh-CN << EOF
我能吞下玻璃而不伤身体。
EOF

Speak Chinese.

$ aspeak -t "你好,世界!" -l zh-CN

Use a custom voice.

$ aspeak -t "你好,世界!" -v zh-CN-YunjianNeural

Custom pitch, rate and style

$ aspeak -t "你好,世界!" -v zh-CN-XiaoxiaoNeural -p 1.5 -r 0.5 -S sad

About This Application

  • I found Azure TTS can synthesize nearly authentic human voice, which is very interesting :laughing:.
  • I wrote this program to learn Azure Cognitive Services.
  • And I use this program daily, because espeak and festival outputs terrible :fearful: audio.
    • But I respect :raised_hands: their maintainers' work, both are good open source software and they can be used off-line.
  • I hope you like it :heart:.

Alternative Applications

Project details


Release history Release notifications | RSS feed

This version

1.1.3

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aspeak-1.1.3.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

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

aspeak-1.1.3-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file aspeak-1.1.3.tar.gz.

File metadata

  • Download URL: aspeak-1.1.3.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for aspeak-1.1.3.tar.gz
Algorithm Hash digest
SHA256 f2b72f9d6129136cc95b3a7d719a6dfe9e709f27a5c7a782ac8e60d664b293e1
MD5 3954d7fdc196d4a9349f55ba009da1f4
BLAKE2b-256 24a09fb846fe286a007191465c58fceb8a77c37a921704101053efad58bf968c

See more details on using hashes here.

File details

Details for the file aspeak-1.1.3-py3-none-any.whl.

File metadata

  • Download URL: aspeak-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for aspeak-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 af6b91615770d37e9d8e13a7347707b457ebc59e34a3575ada4da6ba334ca554
MD5 ee0e647459225ea024928e046be6d01a
BLAKE2b-256 ff335998fda93db8cfa75818307edd2877d1fc7c6532271c9e7f1bb5885d2198

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