Merge pull request #28 from makaveli10/fix_auto_detect_lang
Fix auto detect lang.
This commit is contained in:
@@ -82,6 +82,9 @@ async function startRecord(option) {
|
||||
const socket = new WebSocket(`ws://${option.host}:${option.port}/`);
|
||||
let isServerReady = false;
|
||||
let language = option.language;
|
||||
if (language === null && !option.multilingual) {
|
||||
language = 'en';
|
||||
}
|
||||
socket.onopen = function(e) {
|
||||
socket.send(
|
||||
JSON.stringify({
|
||||
|
||||
@@ -42,6 +42,9 @@ function resampleTo16kHZ(audioData, origSampleRate = 44100) {
|
||||
function startRecording(data) {
|
||||
socket = new WebSocket(`ws://${data.host}:${data.port}/`);
|
||||
language = data.language;
|
||||
if (language === null && !data.useMultilingual) {
|
||||
language = 'en';
|
||||
}
|
||||
socket.onopen = function(e) {
|
||||
socket.send(
|
||||
JSON.stringify({
|
||||
|
||||
@@ -251,7 +251,7 @@ if __name__=="__main__":
|
||||
opt = parser.parse_args()
|
||||
print(opt)
|
||||
multilingual=opt.multilingual,
|
||||
language = opt.language,
|
||||
language = opt.language if opt.multilingual else "en",
|
||||
task = opt.task
|
||||
c = Client(host=opt.host, port=opt.port)
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ class ServeClient:
|
||||
def __init__(self, websocket, task="transcribe", device=None, multilingual=False, language=None):
|
||||
self.data = b""
|
||||
self.frames = b""
|
||||
self.language = language
|
||||
self.language = language if multilingual else "en"
|
||||
self.task = task
|
||||
self.transcriber = WhisperModel(
|
||||
"small" if multilingual else "small.en",
|
||||
|
||||
@@ -288,6 +288,7 @@ class WhisperModel:
|
||||
language,
|
||||
language_probability,
|
||||
)
|
||||
return language, language_probability
|
||||
else:
|
||||
language_probability = 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user