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

--api option was not working correctly #34

Merged
merged 2 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions TranscriberModels.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import whisper
import os
import torch
import GlobalVars


def get_model(use_api: bool, model: str = None):
Expand Down Expand Up @@ -61,6 +62,7 @@ def load_model(self):
class APIWhisperTranscriber:
def __init__(self):
print('Using Open AI API for transcription.')
openai.api_key = GlobalVars.TranscriptionGlobals().api_key
# lang parameter is not required for API invocation. This exists solely
# to support --api option from command line.
# A better solution is to create a base class for APIWhisperTranscriber,
Expand Down
9 changes: 4 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from argparse import RawTextHelpFormatter
import time
import requests
import subprocess
from requests.exceptions import ConnectionError
from AudioTranscriber import AudioTranscriber
from GPTResponder import GPTResponder
import customtkinter as ctk
import TranscriberModels
import subprocess
import interactions
import ui
from language import LANGUAGES_DICT
Expand Down Expand Up @@ -64,8 +64,8 @@ def main():
except ConnectionError:
print('Operating as a standalone client')

global_vars = GlobalVars.TranscriptionGlobals()
config = configuration.Config().get_data()
global_vars = GlobalVars.TranscriptionGlobals(key=config["OpenAI"]["api_key"])

# Command line arg for api_key takes preference over api_key specified in parameters.yaml file
if args.api_key is not None:
Expand Down Expand Up @@ -120,9 +120,8 @@ def main():

ui_cb = ui.ui_callbacks()
global_vars.freeze_button.configure(command=ui_cb.freeze_unfreeze)
update_interval_slider_label.configure(text=f"Update interval: \
{update_interval_slider.get()} \
seconds")
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)

Expand Down
5 changes: 2 additions & 3 deletions ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ def update_response_ui(responder, textbox, update_interval_slider_label,
textbox.configure(state="disabled")

update_interval = int(update_interval_slider.get())
responder.update_response_interval(update_interval)
update_interval_slider_label.configure(text=f"Update interval: \
{update_interval} seconds")
responder.set_response_interval(update_interval)
update_interval_slider_label.configure(text=f"Update Response interval: {update_interval} seconds")

textbox.after(300, update_response_ui, responder, textbox,
update_interval_slider_label, update_interval_slider,
Expand Down