sep for mlx is also ""
This commit is contained in:
parent
ce56264241
commit
7fad0a3ee2
2 changed files with 13 additions and 4 deletions
|
|
@ -164,7 +164,7 @@ class MLXWhisper(ASRBase):
|
||||||
Significantly faster than faster-whisper (without CUDA) on Apple M1.
|
Significantly faster than faster-whisper (without CUDA) on Apple M1.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
sep = " "
|
sep = "" # In my experience in french it should also be no space.
|
||||||
|
|
||||||
def load_model(self, modelsize=None, cache_dir=None, model_dir=None):
|
def load_model(self, modelsize=None, cache_dir=None, model_dir=None):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -166,8 +166,14 @@ class OnlineASRProcessor:
|
||||||
if (
|
if (
|
||||||
len(self.audio_buffer) / self.SAMPLING_RATE > self.buffer_trimming_sec
|
len(self.audio_buffer) / self.SAMPLING_RATE > self.buffer_trimming_sec
|
||||||
): # longer than this
|
): # longer than this
|
||||||
|
|
||||||
|
logger.debug("chunking sentence")
|
||||||
self.chunk_completed_sentence()
|
self.chunk_completed_sentence()
|
||||||
|
|
||||||
|
|
||||||
|
else:
|
||||||
|
logger.debug("not enough audio to trim as a sentence")
|
||||||
|
|
||||||
if self.buffer_trimming_way == "segment":
|
if self.buffer_trimming_way == "segment":
|
||||||
s = self.buffer_trimming_sec # trim the completed segments longer than s,
|
s = self.buffer_trimming_sec # trim the completed segments longer than s,
|
||||||
else:
|
else:
|
||||||
|
|
@ -194,7 +200,10 @@ class OnlineASRProcessor:
|
||||||
def chunk_completed_sentence(self):
|
def chunk_completed_sentence(self):
|
||||||
if self.commited == []:
|
if self.commited == []:
|
||||||
return
|
return
|
||||||
logger.debug("COMPLETED SENTENCE: ", [s[2] for s in self.commited])
|
|
||||||
|
import pdb; pdb.set_trace()
|
||||||
|
raw_text = self.asr.sep.join([s[2] for s in self.commited])
|
||||||
|
logger.debug(f"COMPLETED SENTENCE: {raw_text}")
|
||||||
sents = self.words_to_sentences(self.commited)
|
sents = self.words_to_sentences(self.commited)
|
||||||
for s in sents:
|
for s in sents:
|
||||||
logger.debug(f"\t\tSENT: {s}")
|
logger.debug(f"\t\tSENT: {s}")
|
||||||
|
|
@ -243,7 +252,7 @@ class OnlineASRProcessor:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
cwords = [w for w in words]
|
cwords = [w for w in words]
|
||||||
t = " ".join(o[2] for o in cwords)
|
t = self.asr.sep.join(o[2] for o in cwords)
|
||||||
s = self.tokenize(t)
|
s = self.tokenize(t)
|
||||||
out = []
|
out = []
|
||||||
while s:
|
while s:
|
||||||
|
|
@ -269,7 +278,7 @@ class OnlineASRProcessor:
|
||||||
"""
|
"""
|
||||||
o = self.transcript_buffer.complete()
|
o = self.transcript_buffer.complete()
|
||||||
f = self.to_flush(o)
|
f = self.to_flush(o)
|
||||||
logger.debug(f"last, noncommited: {f}")
|
logger.debug(f"last, noncommited: {f[0]*1000:.0f}-{f[1]*1000:.0f}: {f[2]}")
|
||||||
self.buffer_time_offset += len(self.audio_buffer) / 16000
|
self.buffer_time_offset += len(self.audio_buffer) / 16000
|
||||||
return f
|
return f
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue