mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2026-04-17 12:33:44 +00:00
Fix several typos
This commit is contained in:
parent
249861b65d
commit
2d141b54c5
5 changed files with 19 additions and 19 deletions
|
|
@ -7,8 +7,8 @@ Allows you to enter your inputs in chat mode using your microphone.
|
|||
To adjust your default settings, you can add the following to your settings.yaml file.
|
||||
|
||||
```
|
||||
whisper_stt-whipser_language: chinese
|
||||
whisper_stt-whipser_model: tiny
|
||||
whisper_stt-whisper_language: chinese
|
||||
whisper_stt-whisper_model: tiny
|
||||
whisper_stt-auto_submit: False
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@ input_hijack = {
|
|||
|
||||
# parameters which can be customized in settings.yaml of webui
|
||||
params = {
|
||||
'whipser_language': 'english',
|
||||
'whipser_model': 'small.en',
|
||||
'whisper_language': 'english',
|
||||
'whisper_model': 'small.en',
|
||||
'auto_submit': True
|
||||
}
|
||||
|
||||
startup_device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
||||
WHISPERMODEL = whisper.load_model(params['whipser_model'], device=startup_device)
|
||||
WHISPERMODEL = whisper.load_model(params['whisper_model'], device=startup_device)
|
||||
|
||||
|
||||
def chat_input_modifier(text, visible_text, state):
|
||||
|
|
@ -36,7 +36,7 @@ def chat_input_modifier(text, visible_text, state):
|
|||
return text, visible_text
|
||||
|
||||
|
||||
def do_stt(audio, whipser_language):
|
||||
def do_stt(audio, whisper_language):
|
||||
# use pydub to convert sample_rate and sample_width for whisper input
|
||||
dubaudio = AudioSegment.from_file(io.BytesIO(audio))
|
||||
dubaudio = dubaudio.set_channels(1)
|
||||
|
|
@ -46,20 +46,20 @@ def do_stt(audio, whipser_language):
|
|||
# same method to get the array as openai whisper repo used from wav file
|
||||
audio_np = np.frombuffer(dubaudio.raw_data, np.int16).flatten().astype(np.float32) / 32768.0
|
||||
|
||||
if len(whipser_language) == 0:
|
||||
if len(whisper_language) == 0:
|
||||
result = WHISPERMODEL.transcribe(audio=audio_np)
|
||||
else:
|
||||
result = WHISPERMODEL.transcribe(audio=audio_np, language=whipser_language)
|
||||
result = WHISPERMODEL.transcribe(audio=audio_np, language=whisper_language)
|
||||
return result["text"]
|
||||
|
||||
|
||||
def auto_transcribe(audio, auto_submit, whipser_language):
|
||||
def auto_transcribe(audio, auto_submit, whisper_language):
|
||||
if audio is None or audio == "":
|
||||
print("Whisper received no audio data")
|
||||
return "", ""
|
||||
audio_bytes = base64.b64decode(audio.split(',')[1])
|
||||
|
||||
transcription = do_stt(audio_bytes, whipser_language)
|
||||
transcription = do_stt(audio_bytes, whisper_language)
|
||||
if auto_submit:
|
||||
input_hijack.update({"state": True, "value": [transcription, transcription]})
|
||||
return transcription
|
||||
|
|
@ -78,7 +78,7 @@ def reload_whispermodel(whisper_model_name: str, whisper_language: str, device:
|
|||
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
||||
|
||||
WHISPERMODEL = whisper.load_model(whisper_model_name, device=device)
|
||||
params.update({"whipser_model": whisper_model_name})
|
||||
params.update({"whisper_model": whisper_model_name})
|
||||
if ".en" in whisper_model_name:
|
||||
whisper_language = "english"
|
||||
audio_update = gr.Audio.update(interactive=True)
|
||||
|
|
@ -96,8 +96,8 @@ def ui():
|
|||
with gr.Accordion("Settings", open=False):
|
||||
auto_submit = gr.Checkbox(label='Submit the transcribed audio automatically', value=params['auto_submit'])
|
||||
device_dropd = gr.Dropdown(label='Device', value=str(startup_device), choices=["cuda", "cpu", "none"])
|
||||
whisper_model_dropd = gr.Dropdown(label='Whisper Model', value=params['whipser_model'], choices=["tiny.en", "base.en", "small.en", "medium.en", "tiny", "base", "small", "medium", "large", "turbo"])
|
||||
whisper_language = gr.Dropdown(label='Whisper Language', value=params['whipser_language'], choices=["english", "chinese", "german", "spanish", "russian", "korean", "french", "japanese", "portuguese", "turkish", "polish", "catalan", "dutch", "arabic", "swedish", "italian", "indonesian", "hindi", "finnish", "vietnamese", "hebrew", "ukrainian", "greek", "malay", "czech", "romanian", "danish", "hungarian", "tamil", "norwegian", "thai", "urdu", "croatian", "bulgarian", "lithuanian", "latin", "maori", "malayalam", "welsh", "slovak", "telugu", "persian", "latvian", "bengali", "serbian", "azerbaijani", "slovenian", "kannada", "estonian", "macedonian", "breton", "basque", "icelandic", "armenian", "nepali", "mongolian", "bosnian", "kazakh", "albanian", "swahili", "galician", "marathi", "punjabi", "sinhala", "khmer", "shona", "yoruba", "somali", "afrikaans", "occitan", "georgian", "belarusian", "tajik", "sindhi", "gujarati", "amharic", "yiddish", "lao", "uzbek", "faroese", "haitian creole", "pashto", "turkmen", "nynorsk", "maltese", "sanskrit", "luxembourgish", "myanmar", "tibetan", "tagalog", "malagasy", "assamese", "tatar", "hawaiian", "lingala", "hausa", "bashkir", "javanese", "sundanese"])
|
||||
whisper_model_dropd = gr.Dropdown(label='Whisper Model', value=params['whisper_model'], choices=["tiny.en", "base.en", "small.en", "medium.en", "tiny", "base", "small", "medium", "large", "turbo"])
|
||||
whisper_language = gr.Dropdown(label='Whisper Language', value=params['whisper_language'], choices=["english", "chinese", "german", "spanish", "russian", "korean", "french", "japanese", "portuguese", "turkish", "polish", "catalan", "dutch", "arabic", "swedish", "italian", "indonesian", "hindi", "finnish", "vietnamese", "hebrew", "ukrainian", "greek", "malay", "czech", "romanian", "danish", "hungarian", "tamil", "norwegian", "thai", "urdu", "croatian", "bulgarian", "lithuanian", "latin", "maori", "malayalam", "welsh", "slovak", "telugu", "persian", "latvian", "bengali", "serbian", "azerbaijani", "slovenian", "kannada", "estonian", "macedonian", "breton", "basque", "icelandic", "armenian", "nepali", "mongolian", "bosnian", "kazakh", "albanian", "swahili", "galician", "marathi", "punjabi", "sinhala", "khmer", "shona", "yoruba", "somali", "afrikaans", "occitan", "georgian", "belarusian", "tajik", "sindhi", "gujarati", "amharic", "yiddish", "lao", "uzbek", "faroese", "haitian creole", "pashto", "turkmen", "nynorsk", "maltese", "sanskrit", "luxembourgish", "myanmar", "tibetan", "tagalog", "malagasy", "assamese", "tatar", "hawaiian", "lingala", "hausa", "bashkir", "javanese", "sundanese"])
|
||||
|
||||
audio.change(
|
||||
auto_transcribe, [audio, auto_submit, whisper_language], [shared.gradio['textbox']]).then(
|
||||
|
|
@ -105,7 +105,7 @@ def ui():
|
|||
|
||||
device_dropd.input(reload_whispermodel, [whisper_model_dropd, whisper_language, device_dropd], [whisper_model_dropd, whisper_language, device_dropd, audio])
|
||||
whisper_model_dropd.change(reload_whispermodel, [whisper_model_dropd, whisper_language, device_dropd], [whisper_model_dropd, whisper_language, device_dropd, audio])
|
||||
whisper_language.change(lambda x: params.update({"whipser_language": x}), whisper_language, None)
|
||||
whisper_language.change(lambda x: params.update({"whisper_language": x}), whisper_language, None)
|
||||
auto_submit.change(lambda x: params.update({"auto_submit": x}), auto_submit, None)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue