mallorbc / whisper_mic

Project that allows one to use a microphone with OpenAI whisper.
MIT License
674 stars 154 forks source link

[Feature request][Bug] Improvement needed on the listen() method. Issues related to setup_mic() and listen_loop() method. #46

Closed sankhadeepdutta closed 9 months ago

sankhadeepdutta commented 11 months ago

Proposal related to the listen() method

The current implementation of the listen() method has a mandatory "timeout" parameter whose default value is 3. It can be adjusted, but making the "timeout" parameter mandatory makes the method less flexible for the user to use. The user every time has to calculate the time it would require him to say the query and pass the value to the "timeout" parameter before using it.

Solution

It would make more sense if the listen() method had the ability to auto-detect the duration for which a user gives voice input. It can have the "timeout" parameter as optional.

Issue related to the setup_mic() method

After using the whisper_mic package for my project, I noticed the program starts to capture the audio input just after creating the WhisperMic object. After exploring the code, I found the init() method calls the setup_mic() method, which immediately starts recording after setting up the mic properties.

Solution

I think the setup_mic() method should only handle the task of setting the mic properties. The listening for audio input should be initiated once the user calls for the listen() or listen_loop() method.

Issue related to the listen_loop() method

While using the listen_loop() method with "dictate = False", which will print the transcriptions in the output console, I noticed the output had many line-breaks even if I didn't pause for a second while giving the voice input.

bordercore commented 10 months ago

Thanks. This is exactly what I was looking for.

mallorbc commented 10 months ago

I have reviewed the PR and overall it is great! Thanks!

I didn't see this issue before reviewing the PR. I also noticed the issue you mentioned and think I know what is causing it. I will look to fixing it and then merging the commits. Thanks!

mallorbc commented 10 months ago

I think we should use your solution, but when listen_loop is called, use some variation of the current solution