Skip to content

Commit

Permalink
Refactor requirements.txt to pin numpy version to 1.26.4
Browse files Browse the repository at this point in the history
  • Loading branch information
royshil committed Oct 29, 2024
1 parent 6042fb4 commit de85e7c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ llama-cpp-python
platformdirs
resampy
textual
numpy
numpy==1.26.4
rich
simpler-whisper
huggingface_hub
pyinstaller==6.10.0
python-dotenv
huggingface_hub
huggingface_hub
13 changes: 10 additions & 3 deletions src/audio/Transcriber.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import threading
from simpler_whisper.whisper import ThreadedWhisperModel, set_log_callback
from simpler_whisper.whisper import (
ThreadedWhisperModel,
set_log_callback,
WhisperSegment,
)
from utils import resource_path
import platform
from typing import Callable, List


def my_log_callback(level, message):
Expand Down Expand Up @@ -33,11 +38,13 @@ def _initialize(self):
set_log_callback(my_log_callback)
self.callback = None

def handle_result(self, chunk_id: int, text: str, is_partial: bool):
def handle_result(
self, chunk_id: int, text: List[WhisperSegment], is_partial: bool
):
if self.callback:
self.callback(chunk_id, text, is_partial)

def start(self, callback=None):
def start(self, callback: Callable[[int, List[WhisperSegment], bool], None] = None):
if callback:
self.callback = callback
self.model.start()
Expand Down
9 changes: 6 additions & 3 deletions src/audio/textual_transcription_textarea.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from audio.AudioCapture import AudioCapture
from notes.manager import NoteManager

from simpler_whisper.whisper import WhisperSegment


class TranscriptionTextArea(TextArea):
def __init__(self, uuid: str, *args, **kwargs):
Expand Down Expand Up @@ -43,15 +45,16 @@ def generate_transcription_content(self):
return content

def process_transcription(
self, chunk_id: int, transcription: str, is_partial: bool
self, chunk_id: int, transcription: List[WhisperSegment], is_partial: bool
):
if not transcription or len(transcription) == 0:
return
transcription_str = " ".join([segment.text for segment in transcription])
if is_partial:
self.partial_transcription = transcription
self.partial_transcription = transcription_str
else:
self.transcriptions.append(transcription)
self.partial_transcription = ""
self.transcriptions.append(transcription_str)
self.update_queue.put(True) # Signal that an update is available

def update_transcriptions(self):
Expand Down

0 comments on commit de85e7c

Please sign in to comment.