Skip to content

Commit

Permalink
--api option was not working correctly (#34)
Browse files Browse the repository at this point in the history
--api option was not working correctly even when a good API key was provided.

For transcription local models are working well.
When using --api option and attempting to transcribe using openAI API transcription was not happening because incorrect API Key was being sent to the API.
  • Loading branch information
vivekuppal committed Jul 21, 2023
1 parent 4be26c7 commit 6e53b31
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
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

0 comments on commit 6e53b31

Please sign in to comment.