mirror of
https://github.com/chidiwilliams/buzz.git
synced 2026-03-14 22:55:46 +01:00
Fix for live transcription with Faster whisper (#787)
This commit is contained in:
parent
d737b50134
commit
c19e7acf08
2 changed files with 23 additions and 2 deletions
|
|
@ -6,7 +6,7 @@ import platform
|
|||
import sys
|
||||
from typing import TextIO
|
||||
|
||||
from platformdirs import user_log_dir
|
||||
from platformdirs import user_log_dir, user_cache_dir
|
||||
|
||||
from buzz.assets import APP_BASE_DIR
|
||||
|
||||
|
|
@ -59,6 +59,7 @@ def main():
|
|||
|
||||
logging.debug("app_dir: %s", APP_BASE_DIR)
|
||||
logging.debug("log_dir: %s", log_dir)
|
||||
logging.debug("cache_dir: %s", user_cache_dir("Buzz"))
|
||||
|
||||
app = Application(sys.argv)
|
||||
parse_command_line(app)
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ from buzz.transcriber.whisper_cpp import WhisperCpp, whisper_cpp_params
|
|||
from buzz.transformers_whisper import TransformersWhisper
|
||||
|
||||
import whisper
|
||||
import faster_whisper
|
||||
|
||||
|
||||
class RecordingTranscriber(QObject):
|
||||
|
|
@ -53,6 +54,8 @@ class RecordingTranscriber(QObject):
|
|||
model = whisper.load_model(model_path)
|
||||
elif self.transcription_options.model.model_type == ModelType.WHISPER_CPP:
|
||||
model = WhisperCpp(model_path)
|
||||
elif self.transcription_options.model.model_type == ModelType.FASTER_WHISPER:
|
||||
model = faster_whisper.WhisperModel(model_path)
|
||||
else: # ModelType.HUGGING_FACE
|
||||
model = transformers_whisper.load_model(model_path)
|
||||
|
||||
|
|
@ -113,7 +116,24 @@ class RecordingTranscriber(QObject):
|
|||
transcription_options=self.transcription_options
|
||||
),
|
||||
)
|
||||
else:
|
||||
elif (
|
||||
self.transcription_options.model.model_type
|
||||
== ModelType.FASTER_WHISPER
|
||||
):
|
||||
assert isinstance(model, faster_whisper.WhisperModel)
|
||||
whisper_segments, info = model.transcribe(
|
||||
audio=samples,
|
||||
language=self.transcription_options.language
|
||||
if self.transcription_options.language is not ""
|
||||
else None,
|
||||
task=self.transcription_options.task.value,
|
||||
temperature=self.transcription_options.temperature,
|
||||
initial_prompt=self.transcription_options.initial_prompt,
|
||||
word_timestamps=self.transcription_options.word_level_timings,
|
||||
)
|
||||
result = {"text": " ".join([segment.text for segment in whisper_segments])}
|
||||
|
||||
else: # ModelType.HUGGING_FACE
|
||||
assert isinstance(model, TransformersWhisper)
|
||||
result = model.transcribe(
|
||||
audio=samples,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue