8 Commits

Author SHA1 Message Date
makaveli 9e5ab408cd bump version 0.3.0 2024-02-28 23:39:44 +05:30
Marcus Edel 5e6c26c3a0 Merge pull request #158 from makaveli10/cpu_usage
fix: cpu usage issue.
2024-02-28 09:11:32 -05:00
makaveli10 18b6168807 fix: cpu usage issue 2024-02-28 13:55:37 +05:30
makaveli ec1349360a Merge pull request #157 from makaveli10/trt-multilingual
fix: lanuguage, task prefix in decoder start ids
2024-02-27 18:46:33 +05:30
makaveli10 a41e714801 fix: lanuguage, task prefix in decoder start ids 2024-02-26 23:31:19 -05:00
Marcus Edel 2d16ee552f Merge pull request #156 from makaveli10/fix_docker_image_gpu
Fix docker image gpu.
2024-02-26 09:24:26 -05:00
makaveli10 9699611000 push docker image to ghcr on push to main 2024-02-26 18:50:38 +05:30
makaveli10 ea64d47899 run server with python3 2024-02-26 18:50:18 +05:30
5 changed files with 23 additions and 10 deletions
+2 -2
View File
@@ -77,7 +77,7 @@ jobs:
build-and-push-docker-cpu:
needs: [run-tests, check-code-format]
runs-on: ubuntu-22.04
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v2
@@ -103,7 +103,7 @@ jobs:
needs: [run-tests, check-code-format, build-and-push-docker-cpu]
timeout-minutes: 20
runs-on: ubuntu-22.04
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v2
+1 -1
View File
@@ -30,4 +30,4 @@ COPY whisper_live /app/whisper_live
COPY run_server.py /app
CMD ["python", "run_server.py"]
CMD ["python3", "run_server.py"]
+1 -1
View File
@@ -1 +1 @@
__version__ = "0.2.1"
__version__ = "0.3.0"
+15 -5
View File
@@ -408,6 +408,11 @@ class ServeClientBase(object):
if self.frames_np is not None and self.frames_np.shape[0] > 45*self.RATE:
self.frames_offset += 30.0
self.frames_np = self.frames_np[int(30*self.RATE):]
# check timestamp offset(should be >= self.frame_offset)
# this basically means that there is no speech as timestamp offset hasnt updated
# and is less than frame_offset
if self.timestamp_offset < self.frames_offset:
self.timestamp_offset = self.frames_offset
if self.frames_np is None:
self.frames_np = frame_np.copy()
else:
@@ -575,7 +580,7 @@ class ServeClientTensorRT(ServeClientBase):
warmup_steps (int): Number of steps to warm up the model for.
"""
logging.info("[INFO:] Warming up TensorRT engine..")
mel, _ = self.transcriber.log_mel_spectrogram("tests/jfk.flac")
mel, _ = self.transcriber.log_mel_spectrogram("assets/jfk.flac")
for i in range(warmup_steps):
self.transcriber.transcribe(mel)
@@ -613,7 +618,10 @@ class ServeClientTensorRT(ServeClientBase):
"""
logging.info(f"[WhisperTensorRT:] Processing audio with duration: {input_bytes.shape[0] / self.RATE}")
mel, duration = self.transcriber.log_mel_spectrogram(input_bytes)
last_segment = self.transcriber.transcribe(mel)
last_segment = self.transcriber.transcribe(
mel,
text_prefix=f"<|startoftranscript|><|{self.language}|><|{self.task}|><|notimestamps|>"
)
if last_segment:
self.handle_transcription_output(last_segment, duration)
@@ -793,7 +801,8 @@ class ServeClientFasterWhisper(ServeClientBase):
task=self.task,
vad_filter=self.use_vad,
vad_parameters=self.vad_parameters if self.use_vad else None)
if self.language is None:
if self.language is None and info is not None:
self.set_language(info)
return result
@@ -878,7 +887,9 @@ class ServeClientFasterWhisper(ServeClientBase):
input_sample = input_bytes.copy()
result = self.transcribe_audio(input_sample)
if self.language is None:
if result is None or self.language is None:
self.timestamp_offset += duration
time.sleep(0.25) # wait for voice activity, result is None when no voice activity
continue
self.handle_transcription_output(result, duration)
@@ -929,7 +940,6 @@ class ServeClientFasterWhisper(ServeClientBase):
"""
offset = None
self.current_out = ''
last_segment = None
# process complete segments
if len(segments) > 1:
for i, s in enumerate(segments[:-1]):
+4 -1
View File
@@ -180,7 +180,7 @@ class WhisperModel:
return config
def transcribe(
def transcribe( # noqa: C901
self,
audio: Union[str, BinaryIO, np.ndarray],
language: Optional[str] = None,
@@ -315,6 +315,9 @@ class WhisperModel:
else:
speech_chunks = None
if audio.shape[0] == 0:
return None, None
features = self.feature_extractor(audio)
encoder_output = None