speechmatics / speechmatics-js-sdk

Javascript and Typescript SDK for Speechmatics
MIT License
39 stars 6 forks source link

Translations sometimes not sent #28

Closed adaichendt-tv1 closed 9 months ago

adaichendt-tv1 commented 9 months ago

Hey, I'm currently encountering an issue wherein transcription operates as expected, but translations are inconsistently returned from the SDK (or API??). Restarting the session a few times occasionally resolves the problem, although not consistently. Unfortunately, I haven't been able to identify a clear pattern in this behavior.

In more detail, I am receiving regular AddTranscript messages, but no AddTranslation ones. My audio sources are German online radio senders, which I feed into speechmatics with fetch (see the code snippet below).

My code:

let isRunning = false;
let url = "https://dispatcher.rndfnk.com/br/br24/live/mp3/mid"; // alternative, same issue https://st01.sslstream.dlf.de/dlf/01/high/aac/stream.aac?aggregator=web
let lang_origin = "de";
let lang_target = "en";

const session = new RealtimeSession({
  realtimeUrl: "wss://eu2.rt.speechmatics.com/v2",
  apiKey: process.env.apiKey,
});

session.start({
  transcription_config: {
    language: lang_origin,
    operating_point: "enhanced",
    enable_partials: false,
    max_delay: 5,
    max_delay_mode: "flexible",
  },
  translation_config: {
    target_languages: [lang_target],
  },
  audio_format: { type: "file" },
});

session.addListener("RecognitionStarted", (data) => {
  console.log("RecognitionStarted", data);

  //prepare file stream
  isRunning = true;

  fetch(url)
    .then(
      (res) => {
        const reader = res.body.getReader();

        const pump = () => {
          return reader.read().then(({ done, value }) => {
            if (!isRunning || !session.isConnected) {
              return;
            }

            if (done) {
              session.sendAudio();
              return;
            }

            session.sendAudio(value);
            return pump();
          });
        };

        return pump();
      },
      (err) => {
        console.log(err);
      }
    )
    .finally(() => {
      session.stop();
    });
});

session.addListener("AddTranscript", (message) => {
  console.log("AddTranscript", message);
});

session.addListener("AddTranslation", (message) => {
  console.log("AddTranslation", message);
});

I'd very much appreciate to get some input.

Thanks in Advance! Alex Daichendt

pushon10 commented 9 months ago

Hi @adaichendt-tv1 . Thanks for raising this. This was caused by an internal incident in which the translation services were scaled down in our EU SaaS cluster. However, our Site Reliability team have said that the service should be back up now. I hope this helps.

adaichendt-tv1 commented 9 months ago

Hi, thanks for the quick response! It indeed seems to be working as expected again. Is there by any chance a status page that I can check in case we encounter the same issue again?

shayanbhattacharya commented 9 months ago

@adaichendt-tv1 - Speechmatics status page: https://status.speechmatics.com/

adaichendt-tv1 commented 9 months ago

Thank you! I received no more complaints now.