MCPcopy Create free account
hub / github.com/ModelTC/LightX2V / __init__

Method __init__

lightx2v/utils/va_reader.py:16–52  ·  view source on GitHub ↗
(
        self,
        rank: int,
        world_size: int,
        stream_url: str,
        segment_duration: float = 5.0,
        sample_rate: int = 16000,
        audio_channels: int = 1,
        buffer_size: int = 1,
        prev_duration: float = 0.3125,
        target_rank: int = 0,
    )

Source from the content-addressed store, hash-verified

14
15class VAReader:
16 def __init__(
17 self,
18 rank: int,
19 world_size: int,
20 stream_url: str,
21 segment_duration: float = 5.0,
22 sample_rate: int = 16000,
23 audio_channels: int = 1,
24 buffer_size: int = 1,
25 prev_duration: float = 0.3125,
26 target_rank: int = 0,
27 ):
28 self.rank = rank
29 self.world_size = world_size
30 self.stream_url = stream_url
31 self.segment_duration = segment_duration
32 self.sample_rate = sample_rate
33 self.audio_channels = audio_channels
34 self.prev_duration = prev_duration
35 # int16 = 2 bytes
36 self.chunk_size = int(self.segment_duration * self.sample_rate) * 2
37 self.prev_size = int(self.prev_duration * self.sample_rate) * 2
38 self.prev_chunk = None
39 self.buffer_size = buffer_size
40
41 self.audio_queue = queue.Queue(maxsize=self.buffer_size)
42 self.audio_thread = None
43 self.ffmpeg_process = None
44 self.bytes_buffer = bytearray()
45
46 self.target_rank = target_rank % self.world_size
47
48 self.flag_tensor = torch.tensor([0], dtype=torch.int32).to(device="cuda")
49 self.audio_tensor = torch.zeros(self.chunk_size, dtype=torch.uint8, device="cuda")
50
51 logger.info(f"VAReader initialized for stream: {stream_url} target_rank: {self.target_rank}")
52 logger.info(f"Audio duration per chunk: {segment_duration}s, sample rate: {sample_rate}Hz")
53
54 def start(self):
55 if self.rank == self.target_rank:

Callers

nothing calls this directly

Calls 2

infoMethod · 0.80
toMethod · 0.45

Tested by

no test coverage detected