Giter Site home page Giter Site logo

areebbeigh / winspeech Goto Github PK

View Code? Open in Web Editor NEW
12.0 5.0 6.0 46 KB

Speech recognition and synthesis library for Windows - Python 2 and 3.

Home Page: https://pypi.python.org/pypi/winspeech

License: Apache License 2.0

Batchfile 1.68% Python 98.32%
speech-recognition synthesis-library windows sapi

winspeech's Introduction

winspeech

Speech recognition and synthesis library for Windows - Python 2 and 3.

This is a simple Python library based on the abandoned PySpeech library for Python 2. Requires pywin32.

PyPI: https://pypi.python.org/pypi/winspeech
Doc: https://pythonhosted.org/winspeech/

Installation

> pip install winspeech

Example

# Say anything you type, and write anything you say.
# Stops when you say "turn off" or type "turn off".

import winspeech
import sys

# Start an in-process recognizer. Don't want the shared one with built-in windows commands.
winspeech.initialize_recognizer(winspeech.INPROC_RECOGNIZER)


def callback(phrase, listener):
    print(": %s" % phrase)
    if phrase == "turn off":
        winspeech.say("Goodbye.")
        listener.stop_listening()
        sys.exit()


print("Anything you type, speech will say back.")
print("Anything you say, speech will print out.")
print("Say or type 'turn off' to quit.")

listener = winspeech.listen_for_anything(callback)

while listener.is_listening():
    if sys.version_info.major == 3:
        text = input("> ")
    else:
        text = raw_input("> ")
    if text == "turn off":
        listener.stop_listening()
        sys.exit()
    else:
        winspeech.say(text)

Contributing

Feel free to fork the repo and make any improvements/additions. I love pull requests.

Additional Info

Developer: Areeb Beigh [email protected]
GitHub Repo: https://github.com/areebbeigh/winspeech

winspeech's People

Contributors

areebbeigh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

winspeech's Issues

hello my friends

i am new about it .when i runing "import winspeed " have a long mistake.
about it:
File "C:\Python27\lib\site-packages\winspeech.py", line 49, in
voice = win32com.client.Dispatch("SAPI.SpVoice")
File "C:\Python27\lib\site-packages\win32com\client_init
.py", line 95, in Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 109, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 86, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
pywintypes.com_error: (-2147221005, '\xce\xde\xd0\xa7\xb5\xc4\xc0\xe0\xd7\xd6\xb7\xfb\xb4\xae', None, None)

please help me ...

Feature request: TimeOut parameter?

Hi. First off, a fantastic module, works really well! (within the limits of the Windows speech recognition engine)!

I'm unfortunately a python newbie, but was wondering if there is there any chance of adding a TimeOut parameter to the listen_for_anything function? It would be quite useful when wanting a script to only listen for voice input or command for, say, 10 seconds, and then continue if nothing is received.

Right now I'm using a messy multiprocess loop to handle a timeout, but would be cleaner if a timeout functionality was run inside the function itself.

AttributeError: partially initialized module 'winspeech' has no attribute 'initialize_recognizer'

Edit: This had nothing to do with the winspeech dependency. It was entirely my own dumb mistake. Please disregard.

The example in the readme # Say anything you type, and write anything you say... was working as expected for me with Python 3.9.10 embedded, on Windows 10 64-bit. I'm trying to use it now with installed Python 3.10.2 on the same machine, but I'm getting this error:

λ python winspeech.py
Traceback (most recent call last):
  File "E:\Sync\Projects\py\winspeech.py", line 4, in <module>
    import winspeech
  File "E:\Sync\Projects\py\winspeech.py", line 8, in <module>
    winspeech.initialize_recognizer(winspeech.INPROC_RECOGNIZER)

AttributeError: partially initialized module 'winspeech' has no attribute 'initialize_recognizer' (most likely due to a circular import)

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.