Skip to content

Commit

Permalink
add transcriber
Browse files Browse the repository at this point in the history
  • Loading branch information
dimastatz committed May 4, 2024
1 parent 61095a3 commit 3ebb29d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions python/deepsignal/transcription/transcriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from queue import Queue
from typing import Callable
from threading import Thread

import numpy as np
from whisper import Whisper


Expand Down Expand Up @@ -41,7 +43,11 @@ def _transcribe_loop(self):
if not self.window:
time.sleep(0.1)
else:
buffer = self.to_numpy(self.window)
result = self.model.transcribe(buffer, language="en")
buffer = b"".join(self.window)
arr = (
np.frombuffer(buffer, np.int16).flatten().astype(np.float32)
/ 32768.0
)
result = self.model.transcribe(arr, language="en")
segment_closed = result == self.result
self.callback(result, segment_closed)

0 comments on commit 3ebb29d

Please sign in to comment.