Spaces:
Configuration error
Configuration error
Commit
·
aff8005
1
Parent(s):
069092a
fix: Correct closing logic in AudioStream to prevent discarding remaining data
Browse files
faster_whisper_server/audio.py
CHANGED
@@ -87,12 +87,15 @@ class AudioStream(Audio):
|
|
87 |
while True:
|
88 |
await self.modify_event.wait()
|
89 |
self.modify_event.clear()
|
90 |
-
|
|
|
|
|
|
|
|
|
|
|
91 |
# If `i` shouldn't be set to `duration` after the yield
|
92 |
# because by the time assignment would happen more data might have been added
|
93 |
i_ = i
|
94 |
i = self.duration
|
95 |
# NOTE: probably better to just to a slice
|
96 |
yield self.after(i_).data
|
97 |
-
if self.closed:
|
98 |
-
return
|
|
|
87 |
while True:
|
88 |
await self.modify_event.wait()
|
89 |
self.modify_event.clear()
|
90 |
+
|
91 |
+
if self.closed:
|
92 |
+
if self.duration > i:
|
93 |
+
yield self.after(i).data
|
94 |
+
return
|
95 |
+
if self.duration - i >= min_duration:
|
96 |
# If `i` shouldn't be set to `duration` after the yield
|
97 |
# because by the time assignment would happen more data might have been added
|
98 |
i_ = i
|
99 |
i = self.duration
|
100 |
# NOTE: probably better to just to a slice
|
101 |
yield self.after(i_).data
|
|
|
|