Итак, я пытаюсь построить речь в текстовое приложение в React Native для Android. Я использую библиотеку React-C-C-Adio-Recorder-Player для записи, и для RNF для хранения звук сохраняет в этом месте, но голос не проходит, код приведен ниже: < /p>
import RNFS from 'react-native-fs';
import AudioRecorderPlayer, {
AVEncoderAudioQualityIOSType,
AVEncodingOption,
AVModeIOSOption,
AudioEncoderAndroidType,
AudioSourceAndroidType,
OutputFormatAndroidType,
} from 'react-native-audio-recorder-player';
import { useState } from 'react';
import { Platform } from 'react-native';
const audioRecorderPlayer = new AudioRecorderPlayer();
audioRecorderPlayer.setSubscriptionDuration(0.1);
const useRecording = () => {
const [recording, setRecording] = useState(false);
const [recordingPath, setRecordingPath] = useState('');
const audioSet = {
AudioEncoderAndroid: AudioEncoderAndroidType.AAC,
AudioSourceAndroid: AudioSourceAndroidType.MIC,
AVModeIOS: AVModeIOSOption.measurement,
AVEncoderAudioQualityKeyIOS: AVEncoderAudioQualityIOSType.high,
AVNumberOfChannelsKeyIOS: 2,
AVFormatIDKeyIOS: AVEncodingOption.aac,
OutputFormatAndroid: OutputFormatAndroidType.AAC_ADTS,
};
const startRecording = async () => {
const dirs =
Platform.OS === 'ios'
? RNFS.DocumentDirectoryPath
: RNFS.ExternalDirectoryPath;
console.log('dir', dirs);
const path = Platform.select({
ios: `${dirs}hello.m4a`,
android: `${dirs}/hello.wav`,
}); // File name for your recording
console.log('Recorded File Path:', path);
const result = await audioRecorderPlayer.startRecorder(
path,
audioSet,
true,
);
console.log('result', result);
setRecording(true);
setRecordingPath(result);
};
const stopRecording = async () => {
const result = await audioRecorderPlayer.stopRecorder();
setRecording(false);
};
return {
startRecording,
stopRecording,
setRecording,
recording,
recordingPath,
}
};
export default useRecording;
< /code>
Я пробовал, но звук не проходит. Я ожидаю послушать звук.
Подробнее здесь: https://stackoverflow.com/questions/794 ... act-native
Речь к тексту в React Native ⇐ Android
Форум для тех, кто программирует под Android
1740054296
Anonymous
Итак, я пытаюсь построить речь в текстовое приложение в React Native для Android. Я использую библиотеку React-C-C-Adio-Recorder-Player для записи, и для RNF для хранения звук сохраняет в этом месте, но голос не проходит, код приведен ниже: < /p>
import RNFS from 'react-native-fs';
import AudioRecorderPlayer, {
AVEncoderAudioQualityIOSType,
AVEncodingOption,
AVModeIOSOption,
AudioEncoderAndroidType,
AudioSourceAndroidType,
OutputFormatAndroidType,
} from 'react-native-audio-recorder-player';
import { useState } from 'react';
import { Platform } from 'react-native';
const audioRecorderPlayer = new AudioRecorderPlayer();
audioRecorderPlayer.setSubscriptionDuration(0.1);
const useRecording = () => {
const [recording, setRecording] = useState(false);
const [recordingPath, setRecordingPath] = useState('');
const audioSet = {
AudioEncoderAndroid: AudioEncoderAndroidType.AAC,
AudioSourceAndroid: AudioSourceAndroidType.MIC,
AVModeIOS: AVModeIOSOption.measurement,
AVEncoderAudioQualityKeyIOS: AVEncoderAudioQualityIOSType.high,
AVNumberOfChannelsKeyIOS: 2,
AVFormatIDKeyIOS: AVEncodingOption.aac,
OutputFormatAndroid: OutputFormatAndroidType.AAC_ADTS,
};
const startRecording = async () => {
const dirs =
Platform.OS === 'ios'
? RNFS.DocumentDirectoryPath
: RNFS.ExternalDirectoryPath;
console.log('dir', dirs);
const path = Platform.select({
ios: `${dirs}hello.m4a`,
android: `${dirs}/hello.wav`,
}); // File name for your recording
console.log('Recorded File Path:', path);
const result = await audioRecorderPlayer.startRecorder(
path,
audioSet,
true,
);
console.log('result', result);
setRecording(true);
setRecordingPath(result);
};
const stopRecording = async () => {
const result = await audioRecorderPlayer.stopRecorder();
setRecording(false);
};
return {
startRecording,
stopRecording,
setRecording,
recording,
recordingPath,
}
};
export default useRecording;
< /code>
Я пробовал, но звук не проходит. Я ожидаю послушать звук.
Подробнее здесь: [url]https://stackoverflow.com/questions/79453433/speech-to-text-in-react-native[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия