Add buffer_threshold to WhisperConfig

This commit is contained in:
Yuta Hayashibe 2022-09-29 20:22:36 +09:00
parent f1d85762fc
commit c18f5e4993
2 changed files with 2 additions and 1 deletions

View file

@ -22,6 +22,7 @@ class WhisperConfig(BaseModel):
no_speech_threshold: Optional[float] = 0.6 no_speech_threshold: Optional[float] = 0.6
logprob_threshold: Optional[float] = -1.0 logprob_threshold: Optional[float] = -1.0
compression_ratio_threshold: Optional[float] = 2.4 compression_ratio_threshold: Optional[float] = 2.4
buffer_threshold: Optional[float] = 0.5
class Context(BaseModel, arbitrary_types_allowed=True): class Context(BaseModel, arbitrary_types_allowed=True):

View file

@ -221,7 +221,7 @@ class WhisperStreamingTranscriber:
yield chunk yield chunk
ctx.timestamp += duration ctx.timestamp += duration
if result.temperature > 0.5: if result.temperature > self.config.buffer_threshold:
# do not feed the prompt tokens if a high temperature was used # do not feed the prompt tokens if a high temperature was used
del ctx.buffer_tokens del ctx.buffer_tokens
ctx.buffer_tokens = [] ctx.buffer_tokens = []