Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  voice transcription using audiohook monitor

    Posted 09-29-2025 02:59

    Hello Community,

    My use case is to generate STT transcript (+ translation) using cloud API (I am using Google Speech Recognise API) but it is not working.

    I am able to handle open, close, pause and resume etc. JSON text message and also able to receive binary audio stream (PCMU format, 8K rate).

    Please review following code and advice. I already took GPT help but no success.

    if (isBinary) {
    try {
    let audioBuffer: Buffer;
    if (Buffer.isBuffer(data)) {
    audioBuffer = data;
    } else if (data instanceof ArrayBuffer) {
    audioBuffer = Buffer.from(data);
    } else {
    // Handle other possible types or throw an error
    throw new Error('Unsupported binary data type received');
    }
    // Customer stream
    if (!this.customerStream) {
    this.customerStream = this.client.streamingRecognize({
    config: {
    encoding: 'LINEAR16',
    sampleRateHertz: 8000,
    languageCode: 'en-US',
    enableAutomaticPunctuation: true,
    },
    interimResults: true,
    })
    .on('data', data => {
    const transcript = data.results?.[0]?.alternatives?.[0]?.transcript;
    if (transcript) console.log(`[CUSTOMER] ${transcript}`);
    });
    }

    // Agent stream
    if (!this.agentStream) {
    this.agentStream = this.client.streamingRecognize({
    config: {
    encoding: 'LINEAR16',
    sampleRateHertz: 8000,
    languageCode: 'en-US',
    enableAutomaticPunctuation: true,
    },
    interimResults: true,
    })
    .on('data', data => {
    const transcript = data.results?.[0]?.alternatives?.[0]?.transcript;
    if (transcript) console.log(`[AGENT] ${transcript}`);
    });
    }

    // On binary audio
    const { customer, agent } = this.splitStreamChunk(audioBuffer);
    const customerPcm = this.convertMulawBufferToPCM16LE(customer as Buffer);
    const agentPcm = this.convertMulawBufferToPCM16LE(agent as Buffer);

    this.customerStream.write({ audio_content: customerPcm });
    this.agentStream.write({ audio_content: agentPcm });
    }
    catch(err) {
    console.error('Error processing binary message:', err);
    if (ws.readyState === WebSocket.OPEN) {
    ws.send(JSON.stringify({
    type: 'error',
    message: 'Error processing audio data',
    details: err instanceof Error ? err.message : String(err)
    }));
    }
    }
    }

    #EmbeddableFramework
    #Integrations
    #PlatformAPI
    #PlatformCLI
    #PlatformSDK

    ------------------------------
    Parvez Alam
    ------------------------------


  • 2.  RE: voice transcription using audiohook monitor

    Posted 09-30-2025 07:07

    @Faisal Yousuf Can you please assist?



    ------------------------------
    Parvez Alam
    ------------------------------



  • 3.  RE: voice transcription using audiohook monitor

    Posted 10-06-2025 08:40

    this is resolved as I have to correct convertMulawBufferToPCM16LE for LINEAR16 encoding support.



    ------------------------------
    Parvez Alam
    ------------------------------