Code Monkey home page Code Monkey logo

tts's Introduction

tts - A lightweight python TTS wrapper

tts is a python wrapper around Text To Speech api's

Currently only supports SAPI

Setup

To install, simply use pip and point it at the repository

pip install git+https://github.com/DeepHorizons/tts

To Use

Import the tts package with the api you wish to use

SAPI

import tts.sapi
voice = tts.sapi.Sapi()
voice.say("Hello")
voice.set_voice("Anna")

voice.create_recording('output.wav', "This will be in a wav file")

voice.set_rate(-5)
voice.say("This will be said slower")

voice.set_volume(30)
voice.say("This will be said on a lower volume")

Aside from text, it also support SSML. You'll need to pass the SpeechVoiceSpeakFlags.IsXML flag as a second parameter for the say() function

import tts.sapi
import tts.flags

voice = tts.sapi.Sapi()

voice.say('<PRON SYM = "h eh l ow"/>', tts.flags.SpeechVoiceSpeakFlags.IsXML.value)
voice.say('<speak version="1.0" xmlns="https://www.w3.org/2001/10/synthesis" xml:lang="en-US"><phoneme alphabet="sapi" ph="w er 1 l d"></phoneme></speak>', tts.flags.SpeechVoiceSpeakFlags.IsXML.value)

The SpVoice COM object is available as the voice variable on the instance of the Sapi class. You can access the raw SAPI interface from it. The interface is available at:

https://msdn.microsoft.com/en-us/library/ee125640%28v=vs.85%29.aspx

Properties are assigned and read from, Methods are used like functions. For example, to pause a voice and then to resume it:

voice.voice.Pause()
voice.voice.Resume()

Happy Hacking

tts's People

Contributors

deephorizons avatar jetfontanilla avatar hale6666 avatar

Stargazers

Jason Kane avatar CharlesDerek avatar  avatar Mohammad Reza Ebadollah avatar uncle avatar Berat CANKAR avatar  avatar Toshiaki Tanaka avatar  avatar 鱼子酱 avatar wangjitong avatar holybin avatar  avatar  avatar Álvaro Rodríguez avatar no avatar Avi Avidan avatar JW Hollibush avatar Mai Nishimura avatar  avatar  avatar Michael Chang avatar Denys Zheliezniak avatar  avatar Mr.Robot avatar Danijela Popović avatar Kamil Masalimov avatar Lars Henrik Bolstad avatar Konstantin L. Golovko avatar 15 avatar Daniel Tarazona avatar  avatar  avatar ikmen avatar  avatar Eduardo D. Faustino avatar  avatar (Ray) Jinbiao Yang avatar Mark Traverse avatar Hoàng Chí avatar David wang avatar Scott Lawson avatar  avatar JaredYeah avatar Jianwei Li avatar Thomas Dang avatar Sadeq Sardari avatar Leonarda avatar Yuan Li avatar  avatar Duncan Parkes avatar

Watchers

James Cloos avatar  avatar Danijela Popović avatar Eduardo D. Faustino avatar

tts's Issues

voice.rate doesn't work

voice.rate(3)

Traceback (most recent call last):
File "C:\Users\jason\Google Drive\python\test3.py ", line 9, in
voice.rate(3)
AttributeError: 'Sapi' object has no attribute 'rate'

Switching voices

I'm trying to switch to "Ivona 2 Joey" but not sure how to do it.

import tts.sapi
directory= 'D:\Google Drive\python\'
voice = tts.sapi.Sapi()
voice.set_voice("Ivona 2 Joey")
voice.create_recording(directory+'hello.wav', "Hello")

error:

Voice not found

Traceback (most recent call last):
File "D:\Google drive\python\test3.py", line 6, in
voice.set_voice("Ivona 2 Joey")
File "C:\Python27\lib\site-packages\tts\sapi.py", line 51, in set_voice
self.voice.Voice = self.get_voices(voice)[0]
IndexError: list index out of range

COMError... i think it is a permission issue?

import tts.sapi

directory= 'D:\Google Drive\python\'
voice = tts.sapi.Sapi()
voice.set_voice("IVONA 2 Joey")
voice.create_recording(directory+'hello.wav', "Hello")

I can write to this directory with other python scripts, but not sure why I can't do it here.

Traceback (most recent call last):
File "D:\Google drive\python\test3.py", line 6, in
voice.create_recording(directory+'hello.wav', "Hello")
File "C:\Python27\lib\site-packages\tts\sapi.py", line 104, in create_recording
stream = self._create_stream(filename)
File "C:\Python27\lib\site-packages\tts\sapi.py", line 97, in _create_stream
stream.Open(filename, SpeechLib.SSFMCreateForWrite)
COMError: (-2147287038, None, (None, None, None, 0, None))

Setting volume has no effect

(I'm using this library for the first time (thanks!), so I may be doing something wrong.)

All three sound files generated seem to have the same volume:

import tts.sapi
voice = tts.sapi.Sapi()
voice.set_voice("CUSTOM-HUNGARIAN-VOICE")
voice.voice.Volume = 0
voice.create_recording('test_silent.wav', u'görög ábécé')
voice.voice.Volume = 50
voice.create_recording('test_normal.wav', u'görög ábécé')
voice.voice.Volume = 100
voice.create_recording('test_loud.wav', u'görög ábécé')

I've tried voice.Volume instead of voice.voice.Volume, but same result.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.