-
Notifications
You must be signed in to change notification settings - Fork 34
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
base: main
Are you sure you want to change the base?
Ux improves #14
Conversation
… while transcribing
…elative path using for `source` command
There was a problem hiding this 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.
whisper-dictation.py
Outdated
self.recorder = recorder | ||
self.max_time = max_time | ||
self.timer = None | ||
self.elapsed_time = 0 | ||
self.recorder.set_transcription_events_listener(self) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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:
Python is not "native" for me, so will be glad to see any feedback in case of code smells)