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

Continuous mode not working #148

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
9fde685
Update README.md for Transcribe
vivekuppal Jun 29, 2023
1483fea
Merge pull request #1 from vivekuppal/vu-readme-updates
vivekuppal Jun 29, 2023
391d728
Allow usage without a valid OPEN API key. (#2)
vivekuppal Jun 29, 2023
ab4245d
Update README.md (#3)
vivekuppal Jun 29, 2023
ebb6f2f
Allow user to choose model. Add arguments to main file.
vivekuppal Jun 29, 2023
8f5a595
Code clean up, add linting. (#4)
vivekuppal Jun 30, 2023
59d5c91
UI Text Chronology (#5)
vivekuppal Jun 30, 2023
f772bb8
Update readme with Enhancements. Allow copy of text from UI window. R…
vivekuppal Jun 30, 2023
87a38b1
Save conversation to text. (#9)
vivekuppal Jun 30, 2023
65d6dcf
Add Contextual Information to Responses (#11)
vivekuppal Jun 30, 2023
d1b3c45
Allow users to pause audio transcription. Change the default for gett…
vivekuppal Jul 3, 2023
cfca51a
Update main.py (#15)
abhinavuppal1 Jul 11, 2023
152bad3
Code reorg to separate UI code (#16)
vivekuppal Jul 12, 2023
addf17f
Add support for multiple languages (#18)
vivekuppal Jul 12, 2023
e5cda88
Easy install for non developers on windows (#20)
vivekuppal Jul 18, 2023
9896c1c
Disabled winrar UI (#22)
Adarsha-gg Jul 18, 2023
901501b
When using API, we do not need to specify language, absorb the lang p…
vivekuppal Jul 18, 2023
bd48b61
Language combo fix (#26)
Adarsha-gg Jul 19, 2023
7c9ca88
Added gdrive (#27)
Adarsha-gg Jul 19, 2023
2429c97
Allow usage of API Key in installed version of Transcribe (#28)
vivekuppal Jul 19, 2023
12ef846
updated the drive link (#30)
Adarsha-gg Jul 20, 2023
4be26c7
Add a duration class to easily measure the time taken for an operatio…
vivekuppal Jul 21, 2023
6e53b31
--api option was not working correctly (#34)
vivekuppal Jul 21, 2023
bd42b8c
Initial unit tests for the speech recognition library (#36)
vivekuppal Jul 24, 2023
af87eff
user reported defect fixes. (#39)
vivekuppal Jul 26, 2023
26cfaad
Optimize LLM usage (#40)
vivekuppal Jul 26, 2023
f8d5857
Bug fixes for exceptions observed during usage. Add further plumbing …
vivekuppal Jul 27, 2023
1356a78
Add logging infrastructure (#42)
vivekuppal Jul 27, 2023
a1cc48b
Get Response from LLM on demand (#44)
vivekuppal Jul 28, 2023
ea5f392
Models from open ai site (#43)
Adarsha-gg Jul 28, 2023
b4e03a4
List all active devices (#45)
vivekuppal Aug 1, 2023
85d09ed
Allow user to select input, output audio devices (#48)
vivekuppal Aug 21, 2023
28d1e9a
Disable mic speaker selectively (#49)
vivekuppal Aug 23, 2023
e48bdb8
Add Audio Response for LLM generated content (#50)
vivekuppal Aug 27, 2023
6baa77f
Update, upload latest binaries (#54)
Adarsha-gg Aug 30, 2023
fa55416
Multiturn prompts, bug fixes (#55)
vivekuppal Sep 5, 2023
ce5a1e1
Allow enable/disable speaker and microphone from UI (#56)
Adarsha-gg Sep 6, 2023
e445856
Update gdrive link (#58)
Adarsha-gg Sep 7, 2023
b50f58c
Bring readme up to date with current functionality. Describe content …
vivekuppal Sep 8, 2023
a7ea2cc
Continuous mode broke after updates to the UI.
vivekuppal Sep 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Allow enable/disable speaker and microphone from UI (#56)
* updated the gdrive link to the latest version
* ui additions for enable/disable functionality
  • Loading branch information
Adarsha-gg committed Sep 6, 2023
commit ce5a1e1d2d135a9988889cd755a1f8b0c7f53748
1 change: 1 addition & 0 deletions GlobalVars.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class TranscriptionGlobals(Singleton.Singleton):
# Global for determining whether to seek responses from openAI API
freeze_state: list = None
freeze_button: ctk.CTkButton = None
editmenu: tk.Menu = None
api_key: str = None
filemenu: tk.Menu = None
response_textbox: ctk.CTkTextbox = None
Expand Down
22 changes: 11 additions & 11 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,6 @@ def main():
print('[INFO] Override default speaker with device specified on command line.')
global_vars.speaker_audio_recorder.set_device(index=args.speaker_device_index)

if args.disable_mic:
print('[INFO] Disabling Transcription from the Microphone')
global_vars.user_audio_recorder.disable()

if args.disable_speaker:
print('[INFO] Disabling Transcription from the speaker')
global_vars.speaker_audio_recorder.disable()

try:
subprocess.run(["ffmpeg", "-version"],
stdout=subprocess.DEVNULL,
Expand Down Expand Up @@ -136,6 +128,7 @@ def main():
model = TranscriberModels.get_model(args.api, model=args.model)

root = ctk.CTk()
ui_cb = ui.ui_callbacks()
ui_components = ui.create_ui_components(root)
transcript_textbox = ui_components[0]
global_vars.response_textbox = ui_components[1]
Expand All @@ -146,7 +139,7 @@ def main():
global_vars.filemenu = ui_components[6]
response_now_button = ui_components[7]
read_response_now_button = ui_components[8]

global_vars.editmenu = ui_components[9]
global_vars.user_audio_recorder.record_into_queue(global_vars.audio_queue)

time.sleep(2)
Expand All @@ -155,6 +148,15 @@ def main():
global_vars.freeze_state = [True]
global_vars.convo = conversation.Conversation()

# disable speaker/microphone on startup
if args.disable_speaker:
print('[INFO] Disabling Speaker')
ui_cb.enable_disable_speaker(global_vars.editmenu)

if args.disable_mic:
print('[INFO] Disabling Microphone')
ui_cb.enable_disable_microphone(global_vars.editmenu)

# Transcribe and Respond threads, both work on the same instance of the AudioTranscriber class
global_vars.transcriber = AudioTranscriber(global_vars.user_audio_recorder.source,
global_vars.speaker_audio_recorder.source,
Expand Down Expand Up @@ -189,13 +191,11 @@ def main():
root.grid_columnconfigure(0, weight=2)
root.grid_columnconfigure(1, weight=1)

ui_cb = ui.ui_callbacks()
global_vars.freeze_button.configure(command=ui_cb.freeze_unfreeze)
response_now_button.configure(command=ui_cb.update_response_ui_now)
read_response_now_button.configure(command=ui_cb.update_response_ui_and_read_now)
label_text = f'Update Response interval: {update_interval_slider.get()} seconds'
update_interval_slider_label.configure(text=label_text)

lang_combobox.configure(command=model.change_lang)

ui.update_transcript_ui(global_vars.transcriber, transcript_textbox)
Expand Down
24 changes: 19 additions & 5 deletions ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import app_logging as al
import constants


root_logger = al.get_logger()
UI_FONT_SIZE = 20
last_transcript_ui_update_time: datetime.datetime = datetime.datetime.now()
Expand Down Expand Up @@ -45,9 +44,18 @@ def freeze_unfreeze(self):
root_logger.info(ui_callbacks.freeze_unfreeze.__name__)
self.global_vars.freeze_state[0] = not self.global_vars.freeze_state[0] # Invert the state
self.global_vars.freeze_button.configure(
text="Suggest Responses Continuously" if self.global_vars.freeze_state[0] else "Do Not Suggest Responses Continuously"
value="Suggest Responses Continuously" if self.global_vars.freeze_state[0] else "Do Not Suggest Responses Continuously"
)

# to enable/disable speaker/microphone when args are given or button is pressed
def enable_disable_speaker(self, editmenu):
self.global_vars.speaker_audio_recorder.enabled = not self.global_vars.speaker_audio_recorder.enabled
editmenu.entryconfigure(2, label="Disable Speaker" if self.global_vars.speaker_audio_recorder.enabled else "Enable Speaker")

def enable_disable_microphone(self, editmenu):
self.global_vars.user_audio_recorder.enabled = not self.global_vars.user_audio_recorder.enabled
editmenu.entryconfigure(3, label="Disable Microphone" if self.global_vars.user_audio_recorder.enabled else "Enable Microphone")

def update_response_ui_now(self):
"""Get response from LLM right away
Update the Response UI with the response
Expand Down Expand Up @@ -189,6 +197,12 @@ def create_ui_components(root):
# Add a "Copy To Clipboard" menu item to the file menu
editmenu.add_command(label="Copy Transcript to Clipboard", command=ui_cb.copy_to_clipboard)

# Add "Disable Speaker" menu item to file menu
editmenu.add_command(label="Disable Speaker", command=lambda: ui_cb.enable_disable_speaker(editmenu))

# Add "Disable Microphone" menu item to file menu
editmenu.add_command(label="Disable Microphone", command=lambda: ui_cb.enable_disable_microphone(editmenu))

# See example of add_radiobutton() at https://www.plus2net.com/python/tkinter-menu.php
# Radiobutton would be a good way to display different languages
# lang_menu = tk.Menu(menubar, tearoff=False)
Expand Down Expand Up @@ -230,11 +244,11 @@ def create_ui_components(root):
update_interval_slider.set(2)
update_interval_slider.grid(row=2, column=0, padx=10, pady=10, sticky="nsew")

lang_combobox = ctk.CTkOptionMenu(root, values=list(LANGUAGES_DICT.values()))
lang_combobox.grid(row=3, column=0, padx=200, pady=10, sticky="nsew")
lang_combobox = ctk.CTkOptionMenu(root, width=15, values=list(LANGUAGES_DICT.values()))
lang_combobox.grid(row=3, column=0, ipadx=60, padx=10, sticky="wn")

# Order of returned components is important.
# Add new components to the end
return [transcript_textbox, response_textbox, update_interval_slider,
update_interval_slider_label, freeze_button, lang_combobox,
filemenu, response_now_button, read_response_now_button]
filemenu, response_now_button, read_response_now_button, editmenu]