bugfix
This commit is contained in:
parent
9ea44d5a5d
commit
7d4cf9c494
@ -136,6 +136,7 @@ class AudioTrackVad(MediaStreamTrack):
|
|||||||
Takes path, PCM audio data, and sample rate.
|
Takes path, PCM audio data, and sample rate.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
"""
|
||||||
audio_data = self.to_mono16000_data()
|
audio_data = self.to_mono16000_data()
|
||||||
path = temp_file(suffix='.wav')
|
path = temp_file(suffix='.wav')
|
||||||
# print(f'temp_file={path}')
|
# print(f'temp_file={path}')
|
||||||
@ -150,4 +151,17 @@ class AudioTrackVad(MediaStreamTrack):
|
|||||||
if self.onvoiceend:
|
if self.onvoiceend:
|
||||||
await self.onvoiceend(path)
|
await self.onvoiceend(path)
|
||||||
# print('************over*******')
|
# print('************over*******')
|
||||||
|
return
|
||||||
|
"""
|
||||||
|
|
||||||
|
path = temp_file(suffix='.wav')
|
||||||
|
output_container = av.open(path, 'w')
|
||||||
|
out_stream = output_container.add_stream('pcm_s16le', rate=16000, layout='mono')
|
||||||
|
resampler = AudioResampler(format=out_stream.format, layout=out_stream.layout, rate=out_stream.rate)
|
||||||
|
for frame in self.voiced_frames:
|
||||||
|
for f in resampler.resample(frame):
|
||||||
|
output_container.mux(out_stream.encode(frame))
|
||||||
|
output_container.mux(out_stream.encode())
|
||||||
|
output_container.close()
|
||||||
|
return path
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user