React Native 将用户录制的音频与参考音频片段进行比较,以在语言学习应用程序中进行阴影处理

xdnvmnnf  于 2023-05-07  发布在  React
关注(0)|答案(1)|浏览(170)

我是一名Node.js开发人员,正在使用React Native开发一个语言学习应用程序,我想实现一个“音频比较功能”,以实现阴影功能。
我们的想法是取一个英语电影或戏剧音频文件,将其切成10秒或特定的间隔(让我们称之为音频A),并让用户阴影此音频。该应用程序将记录用户的声音(让我们称之为音频B)。
之后,我想比较音频A和音频B,并显示用户录音(音频B)的差异。
我正在寻找可以帮助我在React Native环境中实现此功能的库或付费服务。作为一个初学者,我很难通过谷歌搜索找到资源。如果有人知道任何合适的图书馆或服务,我将非常感谢您的帮助。
谢谢大家!

bvpmtnay

bvpmtnay1#

有一些库和服务可以帮助您实现音频比较功能,这里是其中的一些:

言语

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);
  }
};

亚马逊转录

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);
  }
};

谷歌云语音转文本

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);
  }
};

希望对你有帮助!

相关问题