rudenick
rudenick

Reputation: 174

Comparing user-recorded audio with a reference audio clip for shadowing in a language learning app

I'm a Node.js developer working on a language learning app using React Native, and I want to implement an 'audio comparison feature' for shadowing purposes.

The idea is to take an English movie or drama audio file, cut it into 10-second or specific intervals (let's call this Audio A), and have the user shadow this audio. The app will record the user's voice (let's call this Audio B).

After that, I'd like to compare Audio A and Audio B and show the differences in the user's recording (Audio B).

I'm looking for libraries or paid services that could help me implement this feature in a React Native environment. As a beginner, I'm having trouble finding resources through Google searches. If anyone knows any suitable libraries or services, I would really appreciate your help.

Thank you!

Upvotes: 0

Views: 227

Answers (1)

Louay Sleman
Louay Sleman

Reputation: 2116

There are a few libraries and services that you can be consider it to help you implement the audio comparison feature and here's some of them:

Speechly

import { SpeechRecognitionService } from '@speechly/react-native-client';

const speechlyClient = SpeechRecognitionService({
  appId: 'your-app-id',
  language: 'en-US',
  enableTelemetry: false,
});

// Start recognition
const startRecognition = async () => {
  try {
    await speechlyClient.start();
  } catch (error) {
    console.log('Error starting recognition:', error);
  }
};

// Stop recognition
const stopRecognition = async () => {
  try {
    await speechlyClient.stop();
  } catch (error) {
    console.log('Error stopping recognition:', error);
  }
};

Amazon Transcribe

import AWS from 'aws-sdk/dist/aws-sdk-react-native';

AWS.config.update({
  region: 'your-region',
  credentials: new AWS.CognitoIdentityCredentials({
    IdentityPoolId: 'your-identity-pool-id',
  }),
});

const transcribeClient = new AWS.TranscribeService();

// Start transcription job
const startTranscriptionJob = async () => {
  try {
    const params = {
      TranscriptionJobName: 'your-job-name',
      Media: {
        MediaFileUri: 'your-media-file-uri',
      },
      MediaFormat: 'wav',
      LanguageCode: 'en-US',
    };
    const data = await transcribeClient.startTranscriptionJob(params).promise();
    console.log(data);
  } catch (error) {
    console.log('Error starting transcription job:', error);
  }
};

Google Cloud Speech-to-Text

import { SpeechClient } from '@google-cloud/speech';

const speechClient = new SpeechClient({
  projectId: 'your-project-id',
  keyFilename: 'your-key-filename.json',
});

// Transcribe audio file
const transcribeAudio = async () => {
  try {
    const [response] = await speechClient.recognize({
      config: {
        encoding: 'LINEAR16',
        sampleRateHertz: 16000,
        languageCode: 'en-US',
      },
      audio: {
        uri: 'your-audio-file-uri',
      },
    });
    console.log(response);
  } catch (error) {
    console.log('Error transcribing audio:', error);
  }
};

Hope it helps you !

Upvotes: 0

Related Questions