Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

speech_recognition does not implemented the vosk wrapper #613

Open
ramleda opened this issue Jun 17, 2022 · 5 comments
Open

speech_recognition does not implemented the vosk wrapper #613

ramleda opened this issue Jun 17, 2022 · 5 comments
Assignees

Comments

@ramleda
Copy link

ramleda commented Jun 17, 2022

I'm trying to use speech_regognition with vosk. But when I try to call the vosk method I receive the following message:

  Traceback (most recent call last):
   File "C:\Users\user\projects\\studies\speechreco.py", line 27, in <module>
   text = recognizer.recognize_vosk(audio)
   AttributeError: 'Recognizer' object has no attribute 'recognize_vosk'. Did you mean: 'recognize_api'?

The method is:

import speech_recognition as speechreco
import vosk

while True:

    try:
        print("begin loop")
        with speechreco.Microphone() as mic:
            recognizer.adjust_for_ambient_noise(mic)
            print("begin listening")
            audio = recognizer.listen(mic)

            text = recognizer.recognize_vosk(audio)
            ...

It looks like the vosk wrapper is not implemented at the version:

vosk - 0.3.42
python - 3.10.4

Need I use a downgrade version?

I follow the sample:

image

@Enhex
Copy link

Enhex commented Jun 17, 2022

version 3.8.1 doesn't include vosk (master does, so I guess it will be in the next release?):
https://github.com/Uberi/speech_recognition/blob/3.8.1/speech_recognition/__init__.py

I'm also interested in using Vosk as it seems to be the only offline option that actually works.

@mattiasu96
Copy link

Yeah same problem, any fix?

@ftnext ftnext self-assigned this Sep 30, 2022
@ftnext
Copy link
Collaborator

ftnext commented Sep 30, 2022

As @Enhex mentioned (Thanks! ❤️),

For example if you install from PyPI, recognize_vosk was not implemented

$ pip install SpeechRecognition
>>> import speech_recognition as speechreco
>>> recognizer = speechreco.Recognizer()
>>> "recognize_vosk" in dir(recognizer)
False

Temporary workaround

Clone this repository and install from source (👉See simpler command by @nshmyrev #613 (comment) )

$ # I recommend to prepare another virtual environment for source installation
$ git clone https://github.com/Uberi/speech_recognition.git
$ cd speech_recognition/
$ pip install -e .
>>> import speech_recognition as speechreco
>>> recognizer = speechreco.Recognizer()
>>> "recognize_vosk" in dir(recognizer)
True

Thanks for reporting this issue. ❤️
Can you try this workaround, @ramleda @mattiasu96 ?

I will prepare for PyPI release.
It is preferable as solution.

@nshmyrev
Copy link

nshmyrev commented Oct 1, 2022

Clone this repository and install from source

You can do it with a single pip command actually:

pip3 install git+https://github.com/Uberi/speech_recognition

@ftnext
Copy link
Collaborator

ftnext commented Oct 2, 2022

@nshmyrev Thanks!
Actually, I misunderstood the project's metadata and was not able to install like pip install SomeProject@git+https://git.repo/some_pkg.git@1.3.1
https://pip.pypa.io/en/stable/cli/pip_install/#examples (example 5)

Your comment gave me suggestions and helped me realize the misunderstanding.
pip install speech-recognition@git+https://github.com/Uberi/speech_recognition.git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants