0

I am trying to use AWS Transcriber SDK for Javascript in Angular and facing issues sending audio to AWS Transcriber WS

This is the error I am facing

Here is my reproducible code

 async createMicrophoneStream() {
    this.audiostream = new MicrophoneStream();

    this.audiostream.setStream(navigator.mediaDevices.getUserMedia({
      video: false,
      audio: true,
    }))

  }
 async startStreaming() {
    const command = new StartStreamTranscriptionCommand({
      LanguageCode: 'en-US',
      MediaEncoding: "pcm",
      MediaSampleRateHertz: 44100,
      AudioStream: this.getAudioStream(),
    });
    // @ts-ignore
    const data = await this.client.send(command);
    // @ts-ignore`your text`
    for await (const event of data.TranscriptResultStream) {
      // @ts-ignore
      for (const result of event.TranscriptEvent.Transcript.Results || []) {
        if (result.IsPartial === false) {
          // @ts-ignore
          const noOfResults = result.Alternatives[0].Items.length;
          for (let i = 0; i < noOfResults; i++) {
            // @ts-ignore
            console.log(result.Alternatives[0].Items[i].Content);
          }
        }
      }
    }
  }

  async *getAudioStream() {
    for await (const chunk of this.audiostream) {
      if (chunk.length <= 44100) {
        yield {
          AudioEvent: {
            AudioChunk: encodePcm(chunk),
          },
        };
      }
    }
  };

I should have been receving the translation text from AWS Transcriber client but before it could reach AWS Transciber I get an error

Murtaza Z
  • 13
  • 3

0 Answers0