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
Add support for multiple languages (#18)
* Add support for multi languages.
  • Loading branch information
vivekuppal committed Jul 12, 2023
commit addf17f1c640b11019dd7065ab0c98bb6b1584c2
30 changes: 24 additions & 6 deletions TranscriberModels.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,47 @@ def get_model(use_api: bool, model: str = None):
class WhisperTranscriber:
def __init__(self, model: str = 'tiny'):
model_filename = model + '.en.pt'
self.lang = 'en'
self.model = model

if not os.path.isfile(model_filename):
print(f'Could not find the model file: {model_filename}')
print(f'Download the model file and add it to the directory: \
{os.getcwd()}')
print('small model is available at: \
print('tiny multi-lingual model is available at: \
https://drive.google.com/file/d/1M4AFutTmQROaE9xk2jPc5Y4oFRibHhEh/view?usp=drive_link')
print('small english model is available at: \
https://drive.google.com/file/d/1vhtoZCwfYGi5C4jK1r-QVr5GobSBnKiH/view?usp=drive_link')
print('base model is available at: \
print('small multi-lingual model is available at: \
https://drive.google.com/file/d/1bl8er_st8WPZKPWVeYMNlaUi9IzR3jEZ/view?usp=drive_link')
print('base english model is available at: \
https://drive.google.com/file/d/1E44DVjpfZX8tSrSagaDJXU91caZOkwa6/view?usp=drive_link')
print('base multi-lingual model is available at: \
https://drive.google.com/file/d/1UcqU_D0cPFqq_nckSfstMBfogFsvR-KR/view?usp=drive_link')
exit()

self.audio_model = whisper.load_model(os.path.join(os.getcwd(),
model_filename))
self.model_filename = os.path.join(os.getcwd(), model_filename)
self.audio_model = whisper.load_model(self.model_filename)
print(f'[INFO] Whisper using GPU: {str(torch.cuda.is_available())}')

def get_transcription(self, wav_file_path):
try:
result = self.audio_model.transcribe(wav_file_path, fp16=torch.cuda.is_available())
result = self.audio_model.transcribe(wav_file_path,
fp16=torch.cuda.is_available(), language=self.lang)
except Exception as exception:
print(exception)
return ''
return result['text'].strip()

def change_lang(self, lang: str):
self.lang = lang
self.load_model()

def load_model(self):
if self.lang == "en":
self.audio_model = whisper.load_model(os.path.join(os.getcwd(), self.model + 'en.pt'))
else:
self.audio_model = whisper.load_model(os.path.join(os.getcwd(), self.model + '.pt'))


class APIWhisperTranscriber:
def __init__(self):
Expand Down
101 changes: 101 additions & 0 deletions language.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
LANGUAGES = {
"en": "english",
"zh": "chinese",
"de": "german",
"es": "spanish",
"ru": "russian",
"ko": "korean",
"fr": "french",
"ja": "japanese",
"pt": "portuguese",
"tr": "turkish",
"pl": "polish",
"ca": "catalan",
"nl": "dutch",
"ar": "arabic",
"sv": "swedish",
"it": "italian",
"id": "indonesian",
"hi": "hindi",
"fi": "finnish",
"vi": "vietnamese",
"iw": "hebrew",
"uk": "ukrainian",
"el": "greek",
"ms": "malay",
"cs": "czech",
"ro": "romanian",
"da": "danish",
"hu": "hungarian",
"ta": "tamil",
"no": "norwegian",
"th": "thai",
"ur": "urdu",
"hr": "croatian",
"bg": "bulgarian",
"lt": "lithuanian",
"la": "latin",
"mi": "maori",
"ml": "malayalam",
"cy": "welsh",
"sk": "slovak",
"te": "telugu",
"fa": "persian",
"lv": "latvian",
"bn": "bengali",
"sr": "serbian",
"az": "azerbaijani",
"sl": "slovenian",
"kn": "kannada",
"et": "estonian",
"mk": "macedonian",
"br": "breton",
"eu": "basque",
"is": "icelandic",
"hy": "armenian",
"ne": "nepali",
"mn": "mongolian",
"bs": "bosnian",
"kk": "kazakh",
"sq": "albanian",
"sw": "swahili",
"gl": "galician",
"mr": "marathi",
"pa": "punjabi",
"si": "sinhala",
"km": "khmer",
"sn": "shona",
"yo": "yoruba",
"so": "somali",
"af": "afrikaans",
"oc": "occitan",
"ka": "georgian",
"be": "belarusian",
"tg": "tajik",
"sd": "sindhi",
"gu": "gujarati",
"am": "amharic",
"yi": "yiddish",
"lo": "lao",
"uz": "uzbek",
"fo": "faroese",
"ht": "haitian creole",
"ps": "pashto",
"tk": "turkmen",
"nn": "nynorsk",
"mt": "maltese",
"sa": "sanskrit",
"lb": "luxembourgish",
"my": "myanmar",
"bo": "tibetan",
"tl": "tagalog",
"mg": "malagasy",
"as": "assamese",
"tt": "tatar",
"haw": "hawaiian",
"ln": "lingala",
"ha": "hausa",
"ba": "bashkir",
"jw": "javanese",
"su": "sundanese",
}
18 changes: 14 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import interactions
import ui
from requests.exceptions import ConnectionError
from language import LANGUAGES


def main():
Expand All @@ -27,11 +28,17 @@ def main():
cmd_args.add_argument('-m', '--model', action='store', choices=['tiny', 'base', 'small'],
default='tiny',
help='Specify the model to use for transcription.'
'\nBy default tiny model is part of the install.'
'\nbase model has to be downloaded from the link \
'\nBy default tiny english model is part of the install.'
'\ntiny multi-lingual model has to be downloaded from the link \
https://drive.google.com/file/d/1M4AFutTmQROaE9xk2jPc5Y4oFRibHhEh/view?usp=drive_link'
'\nbase english model has to be downloaded from the link \
https://drive.google.com/file/d/1E44DVjpfZX8tSrSagaDJXU91caZOkwa6/view?usp=drive_link'
'\nsmall model has to be downloaded from the link \
'\nbase multi-lingual model has to be downloaded from the link \
https://drive.google.com/file/d/1UcqU_D0cPFqq_nckSfstMBfogFsvR-KR/view?usp=drive_link'
'\nsmall english model has to be downloaded from the link \
https://drive.google.com/file/d/1vhtoZCwfYGi5C4jK1r-QVr5GobSBnKiH/view?usp=drive_link'
'\nsmall multi-lingual model has to be downloaded from the link \
https://drive.google.com/file/d/1bl8er_st8WPZKPWVeYMNlaUi9IzR3jEZ/view?usp=drive_link'
'\nOpenAI has more models besides the ones specified above.'
'\nThose models are prohibitive to use on local machines because \
of memory requirements.')
Expand Down Expand Up @@ -65,7 +72,8 @@ def main():
freeze_button = ui_components[4]
copy_button = ui_components[5]
save_file_button = ui_components[6]
transcript_button = ui_components[7]
lang_combobox = ui_components[7]
transcript_button = ui_components[8]

audio_queue = queue.Queue()

Expand Down Expand Up @@ -136,6 +144,8 @@ def set_transcript_state():
{update_interval_slider.get()} \
seconds")

lang_combobox.configure(command=model.change_lang)

ui.update_transcript_ui(transcriber, transcript_textbox)
ui.update_response_ui(responder, response_textbox, update_interval_slider_label,
update_interval_slider, freeze_state)
Expand Down
6 changes: 5 additions & 1 deletion ui.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import customtkinter as ctk
import AudioTranscriber
import prompts
from language import LANGUAGES


def write_in_textbox(textbox: ctk.CTkTextbox, text: str):
Expand Down Expand Up @@ -91,11 +92,14 @@ def create_ui_components(root):
save_file_button = ctk.CTkButton(root, text="Save Audio Transcript to File", command=None)
save_file_button.grid(row=3, column=0, padx=10, pady=3, sticky="nsew")

lang_combobox = ctk.CTkOptionMenu(root, values=list(LANGUAGES.values()))
lang_combobox.grid(row=4, column=1, padx=200, pady=10, sticky="nsew")

transcript_button = ctk.CTkButton(root, text="Pause Transcript", command=None)
transcript_button.grid(row=4, column=0, padx=10, pady=3, sticky="nsew")

# 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, copy_button,
save_file_button, transcript_button]
save_file_button, lang_combobox, transcript_button]