Browse Source
Add layout in output
Signed-off-by: Jael Gu <mengjia.gu@zilliz.com>
main
1 changed files with
9 additions and
2 deletions
-
audio_decoder.py
|
|
@ -5,7 +5,13 @@ import av |
|
|
|
from towhee.operator.base import Operator |
|
|
|
|
|
|
|
|
|
|
|
AudioOutput = NamedTuple("Outputs", [("audio_frame", 'ndarray'), ('sample_rate', 'int'), ("TIMESTAMP", 'int')]) |
|
|
|
AudioOutput = NamedTuple( |
|
|
|
"Outputs", |
|
|
|
[("audio_frame", 'ndarray'), |
|
|
|
('sample_rate', 'int'), |
|
|
|
('layout', 'str'), |
|
|
|
("TIMESTAMP", 'int')] |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
class AudioDecoder(Operator): |
|
|
@ -21,5 +27,6 @@ class AudioDecoder(Operator): |
|
|
|
for frame in in_container.decode(stream): |
|
|
|
timestamp = int(frame.time * 1000) |
|
|
|
sample_rate = frame.sample_rate |
|
|
|
layout = frame.layout.name |
|
|
|
ndarray = frame.to_ndarray() |
|
|
|
yield AudioOutput(ndarray, sample_rate, timestamp) |
|
|
|
yield AudioOutput(ndarray, sample_rate, layout, timestamp) |
|
|
|