Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into tensorrt_backend
Browse files Browse the repository at this point in the history
  • Loading branch information
makaveli10 committed Jan 19, 2024
2 parents 1e2faa3 + 0942dc2 commit 986823d
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Audio-Transcription-Chrome/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ document.addEventListener("DOMContentLoaded", function () {

// Send a message to the background script to start capturing
let host = "localhost";
let port = "5901";
let port = "9090";
const useCollaboraServer = useServerCheckbox.checked;
if (useCollaboraServer){
host = "transcription.kurg.org"
Expand Down
2 changes: 1 addition & 1 deletion Audio-Transcription-Firefox/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ document.addEventListener("DOMContentLoaded", function() {

startButton.addEventListener("click", function() {
let host = "localhost";
let port = "5901";
let port = "9090";
const useCollaboraServer = useServerCheckbox.checked;

if (useCollaboraServer){
Expand Down
2 changes: 1 addition & 1 deletion whisper_live/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__="0.0.10"
__version__="0.0.11"
24 changes: 19 additions & 5 deletions whisper_live/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ class Client:
INSTANCES = {}

def __init__(
self, host=None, port=None, is_multilingual=False, lang=None, translate=False, model_size="small"
self,
host=None,
port=None,
is_multilingual=False,
lang=None,
translate=False,
model="small",
):
"""
Initializes a Client instance for audio recording and streaming to a server.
Expand Down Expand Up @@ -81,8 +87,9 @@ def __init__(
self.disconnect_if_no_response_for = 15
self.multilingual = is_multilingual
self.language = lang
self.model_size = model_size
self.model = model
self.server_error = False

if translate:
self.task = "translate"

Expand Down Expand Up @@ -220,7 +227,7 @@ def on_open(self, ws):
"multilingual": self.multilingual,
"language": self.language,
"task": self.task,
"model_size": self.model_size,
"model": self.model,
}
)
)
Expand Down Expand Up @@ -505,8 +512,15 @@ class TranscriptionClient:
transcription_client()
```
"""
def __init__(self, host, port, is_multilingual=False, lang=None, translate=False, model_size="small"):
self.client = Client(host, port, is_multilingual, lang, translate, model_size)
def __init__(self,
host,
port,
is_multilingual=False,
lang=None,
translate=False,
model="small",
):
self.client = Client(host, port, is_multilingual, lang, translate, model)

def __call__(self, audio=None, hls_url=None):
"""
Expand Down
19 changes: 13 additions & 6 deletions whisper_live/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ def recv_audio(self,
websocket.close()
del websocket
return

# validate custom model
if custom_model_path is not None and os.path.exists(custom_model_path):
logging.info(f"Using custom model {custom_model_path}")
options["model"] = custom_model_path

if self.backend == "tensorrt":
try:
Expand Down Expand Up @@ -561,7 +566,7 @@ def __init__(
client_uid=None,
model="small",
initial_prompt=None,
vad_parameters=None
vad_parameters=None,
):
"""
Initialize a ServeClient instance.
Expand All @@ -583,6 +588,7 @@ def __init__(
"tiny", "tiny.en", "base", "base.en", "small", "small.en",
"medium", "medium.en", "large-v2", "large-v3",
]

self.multilingual = multilingual
if not os.path.exists(model):
self.model_size_or_path = self.get_model_size(model)
Expand Down Expand Up @@ -633,12 +639,13 @@ def get_model_size(self, model_size):
)
return None

if model_size in ["large-v2", "large-v3"]:
if model_size.endswith("en") and self.multilingual:
logging.info(f"Setting multilingual to false with {model_size} which is english only model.")
self.multilingual = False

if not model_size.endswith("en") and not self.multilingual:
logging.info(f"Setting multilingual to true with multilingual model {model_size}.")
self.multilingual = True
return model_size

if not self.multilingual:
model_size = model_size + ".en"

return model_size

Expand Down

0 comments on commit 986823d

Please sign in to comment.