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

Ux improves #14

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Ux improves #14

wants to merge 7 commits into from

Conversation

raslab
Copy link

@raslab raslab commented Feb 17, 2024

I was wondering to found such a great dictation tool on github! Thanks for author, looks I will use this tool for daily basis, instead of macos system dictation tool!)

But, for make life easier on daily basis usage, I had found usefull few improvements, which will glad to share to author and community:

  1. Whisper models added few new models, I added it support to argumens
  2. In case of using few languages for dictation, rendering which exactly language now selected in idle time appers to pretty useful - added this improvement also
  3. Also, super usefull appears to show transcribing status (some animated dots "...") - also added this feature.

Python is not "native" for me, so will be glad to see any feedback in case of code smells)

Copy link
Owner

@foges foges left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution. I think the additions make sense. Due to some issues with the way the code was originally written I think there is room for making the original code, and your changes cleaner. Would love to see this merged.

self.recorder = recorder
self.max_time = max_time
self.timer = None
self.elapsed_time = 0
self.recorder.set_transcription_events_listener(self)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking a bit more through the code I think the way I structured it is a bit messy. There isn't really a good reason why the transcriber is passed into the recorder. I think the way it should be set up is:

class Recorder:
    def __init__(self):
        self.recording = False
  
    def start(self, callback, language=None):
        thread = threading.Thread(target=self._record_impl, args=(callback, language,))
        thread.start()

    def _record_impl(self, callback, language):
        ...
        callback(audio_data_fp32, language)



class StatusBarApp(..):

  def start_app(self, _): 
    def _callback(audio_data_fp32):
       self.is_transcribing = True
       self.update_title()
       self.transcriber.transcribe(audio_data_fp32, language)
       self.is_transcribing = False
       self.update_title()
      
    self.recorder.start(_callback, self.current_language)
    

if __name__ == "__main__":
    ...
    transcriber = SpeechTranscriber(model)
    recorder = Recorder()
    
    app = StatusBarApp(transcriber, recorder, args.language, args.max_time)

This would avoid all the listeners

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, now code looks much better, good note)

@@ -114,21 +126,35 @@ def __init__(self, recorder, languages=None, max_time=None):
self.menu = menu
self.menu['Stop Recording'].set_callback(None)

self.started = False
self.is_recording = False
self.is_transcribing = False
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a self.title = "" here. It's not specific to your change, but it's hard to see here where the title is coming from.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's updating in self.update_title() at the end of this block, but maybe will be better to add this line also at the start of the block to make it more clear. Yep, not a problem.

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

Successfully merging this pull request may close these issues.

2 participants