CoolFace
Apppublic

philippe83260/seamless-streaming

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
transcoder_helpers.py44 linesDownload Raw Back to src
1import logging2 3logger = logging.getLogger("socketio_server_pubsub")4 5 6def get_transcoder_output_events(transcoder) -> list:7    speech_and_text_output = transcoder.get_buffered_output()8    if speech_and_text_output is None:9        logger.debug("No output from transcoder.get_buffered_output()")10        return []11 12    logger.debug(f"We DID get output from the transcoder! {speech_and_text_output}")13 14    lat = None15 16    events = []17 18    if speech_and_text_output.speech_samples:19        events.append(20            {21                "event": "translation_speech",22                "payload": speech_and_text_output.speech_samples,23                "sample_rate": speech_and_text_output.speech_sample_rate,24            }25        )26 27    if speech_and_text_output.text:28        events.append(29            {30                "event": "translation_text",31                "payload": speech_and_text_output.text,32            }33        )34 35    for e in events:36        e["eos"] = speech_and_text_output.final37 38    # if not latency_sent:39    #     lat = transcoder.first_translation_time()40    #     latency_sent = True41    #     to_send["latency"] = lat42 43    return events44