Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9e5ab408cd | |||
| 5e6c26c3a0 | |||
| 18b6168807 | |||
| ec1349360a | |||
| a41e714801 | |||
| 2d16ee552f | |||
| 9699611000 | |||
| ea64d47899 |
@@ -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
|
||||
|
||||
|
||||
@@ -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 @@
|
||||
__version__ = "0.2.1"
|
||||
__version__ = "0.3.0"
|
||||
|
||||
+15
-5
@@ -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]):
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user