Skip to main content

a python library that helps you to control the sapi5 TTS

Project description

NBSapi

what is NBSapi

the NBSapi is a python library that can help you to convert your text to speech, where you can hear it directly or save it to an audio file.
it currently working only on windows with sapi5

requirements

to use the NBSapi you just need to install the comtypes library by using
pip install comtypes

install NBSapi

to install NBSapi you can use PIP
pip install NBSapi

usage

to use the library you need to import it
from NBSapi import NBSapi
import time
#load the class
TTS = NBSapi()
#speak a text and wait
TTS.Speak("hello")
#speak without wait, (note: this step is required if you want to control the speech)
TTS.Speak("hello", 1)
#wait 0.1 sec before stop the speech
time.sleep(0.1)
TTS.Stop()

whats new

  • solved a lot of problems
  • added function to check if sapi is avalable and working without any problems

class functions

this library has a lot of functions that make the sapi 5 tts easy

is_sapi

is_sapi()
this function will return true or false\

Speak

Speak(text (string), flag (int))
this is the function that will speek text
you can use the flags that exists on the lib file\

SpeakToFile

SpeakToFile(text (string), file (string), flags (int))
create an audio file with the giving text and path

Pause

Pause()
pause the speech

Resume

Resume()
resume the speech

Stop

Stop()
Stop the Speech

GetVoice

GetVoice()
get the current voice information as a dict

SetVoice

SetVoice(voice (index, description, attribute, or object), key ("by_index", "by_description", "by_attribute", or "" for voice object))
Set the current voice, even by description, by attribute, by index starting from 0, or by object

GetVolume

GetVolume()
Get the Current volume

SetVolume

SetVolume(vol (int))
set the Current volume

GetRate

GetRate()
Get the Current Rate

SetRate

SetRate(Rate (int))
Set the Rate of the voice Between -10 and 10

GetVoices

GetVoices(attrs = "")
Get a list of dicts, each item has a voice information
so, you can use this list indexes to set the voice, it has the same order.
here also you can use attributes to get just the voices you need (take a look to tests folder)

GetAttribute

GetAttribute(attr (string))
get an attribute of the selected voice such as Name, Age, Language, and Gender.

GetStatus(

GetStatus(Property (string))
Get a state of any thing you want, you can use the declared variable that start with STS_

GetObject

get the current SPVoice object

notes:

this library is new, so i will add a features to it as i can.
if you have any idea about this library please help with it.

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

NBSapi-0.6.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

NBSapi-0.6-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

Details for the file NBSapi-0.6.tar.gz.

File metadata

  • Download URL: NBSapi-0.6.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for NBSapi-0.6.tar.gz
Algorithm Hash digest
SHA256 cb566b70eb918d0fb4e7d5f2e25c9d289cc3d3e3a9f5a9d270916253b7fdfe8f
MD5 c9efe3e7a114d15372f87bfafbe5af81
BLAKE2b-256 9132811c64e83e0bec21df9913a801b4c378ed2513cd22f23f177411328f6c50

See more details on using hashes here.

File details

Details for the file NBSapi-0.6-py3-none-any.whl.

File metadata

  • Download URL: NBSapi-0.6-py3-none-any.whl
  • Upload date:
  • Size: 19.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for NBSapi-0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 59c5f6fc62ae8b8acae6d0e88c8af0420f8a1213ded410d0985f667bde51d5a9
MD5 ba9a1af110feb5e51686123f279bdb16
BLAKE2b-256 d0602c7f02a86665f0163430e3bba6e72da2f6b5baa34a560cce6797f5871865

See more details on using hashes here.

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