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

SpeechRecognition+Whisper on Windows 10 may need added code #632

Closed
ftnext opened this issue Nov 20, 2022 · 1 comment
Closed

SpeechRecognition+Whisper on Windows 10 may need added code #632

ftnext opened this issue Nov 20, 2022 · 1 comment
Labels
whisper Features related to Whisper wontfix

Comments

@ftnext
Copy link
Collaborator

ftnext commented Nov 20, 2022

Thanks to Fungus for sharing.

Expected behaviour

There is no failure.

Actual behaviour

The following code fails unless the code of the Shared workaround

with tempfile.NamedTemporaryFile(suffix=".wav") as f:
f.write(audio_data.get_wav_data())
f.flush()
result = self.whisper_model[model].transcribe(
f.name,
language=language,
task="translate" if translate else None,
fp16=torch.cuda.is_available(),
**transcribe_options
)

Shared workaround

+        with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as f:
-        with tempfile.NamedTemporaryFile(suffix=".wav") as f:
            f.write(audio_data.get_wav_data())
            f.flush()
            result = self.whisper_model[model].transcribe(
                f.name,
                language=language,
                task="translate" if translate else None,
                fp16=torch.cuda.is_available(),
                **transcribe_options
            )
+            f.close()
+            os.remove(f.name)

System information

(Delete all the statements that don't apply.)

My system is Windows 10.

My Python version is . (You can check this by running python -V.)

My Pip version is . (You can check this by running pip -V.)

My SpeechRecognition library version is . (You can check this by running python -c "import speech_recognition as sr;print(sr.__version__)".)

My PyAudio library version is / I don't have PyAudio installed. (You can check this by running python -c "import pyaudio as p;print(p.__version__)".)

My microphones are: (You can check this by running python -c "import speech_recognition as sr;print(sr.Microphone.list_microphone_names())".)

My working microphones are: (You can check this by running python -c "import speech_recognition as sr;print(sr.Microphone.list_working_microphones())".)

I installed PocketSphinx from . (For example, from the Debian repositories, from Homebrew, or from the source code.)

@ftnext
Copy link
Collaborator Author

ftnext commented Jan 9, 2023

I updated the implementation to not use tempfile in #647.
It will be included the next release (maybe 3.9.1)

@ftnext ftnext closed this as completed Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
whisper Features related to Whisper wontfix
Projects
None yet
Development

No branches or pull requests

1 participant