mirror of
https://github.com/damp11113/xHE-Opus.git
synced 2025-04-27 22:48:08 +00:00
30 lines
705 B
Python
30 lines
705 B
Python
import pyaudio
|
|
from libxheopus import DualOpusDecoder, CustomFileContainer
|
|
|
|
# Initialize PyAudio
|
|
p = pyaudio.PyAudio()
|
|
|
|
decoder = DualOpusDecoder()
|
|
|
|
streamoutput = p.open(format=pyaudio.paInt16, channels=2, rate=48000, output=True)
|
|
|
|
file = open(r"test.xopus", 'rb')
|
|
|
|
line = file.read().split(b"\\xa")
|
|
|
|
deserialized_container = CustomFileContainer.deserialize(line[0])
|
|
print(deserialized_container.metadata)
|
|
|
|
try:
|
|
for data in line[1:]:
|
|
if data:
|
|
streamoutput.write(decoder.decode(data))
|
|
|
|
|
|
except KeyboardInterrupt:
|
|
print("Interrupted by user")
|
|
finally:
|
|
# Clean up PyAudio streams and terminate PyAudio
|
|
streamoutput.stop_stream()
|
|
streamoutput.close()
|
|
p.terminate() |