-
Notifications
You must be signed in to change notification settings - Fork 103
TypeError: undefined is not an object(evaluating '_reactNativeAudioRecord.AudioRecord.init') #40
Comments
Start by removing irrelevant code to the problem. |
The same happens for me if you can help meimport { StatusBar } from 'expo-status-bar'; Audio.requestPermissionsAsync(); export default function App() { const options = { **
** return ( |
Did anyone figure this out? I am having the same issue. |
Dear, after making the above recommendations, now the log is sending me the following error message LOG Este es el error: {"err": "User: arn:aws:sts::649856891400:assumed-role/amplify-allymobile-dev-82957-unauthRole/CognitoIdentityCredentials is not authorized to perform: transcribe:StartStreamTranscriptionWebSocket because no identity-based policy allows the transcribe:StartStreamTranscriptionWebSocket action"} Anexo Config `/* eslint-disable */ const awsmobile = { export default awsmobile; sepeechAlly-template.json |
My code is almost same as App1.js but i'm getting warning as TypeError: undefined is not an object(evaluating '_reactNativeAudioRecord.AudioRecord.init') when i'm calling init and also similar warning for other calls (start(),stop() etc.) .Also I'm getting undefined from stop( ) call which should return path of the audio file.
My Code:-
class App extends Component {
sound = null;
state = {
audioFile: '',
recording: false,
loaded: false,
paused: true
};
async componentDidMount() {
await this.checkPermission();
// await this.checkPermission1();
// await this.checkPermission2();
const options = {
sampleRate: 16000,
channels: 1,
bitsPerSample: 16,
audioSource: 1,
};
AudioRecord.init(options);
// AudioRecord.on('data', data => {
// const chunk = Buffer.from(data, 'base64');
// console.log('chunk size', chunk.byteLength);
// // do something with audio chunk
// });
}
checkPermission = async () => {
try {
const granted = await PermissionsAndroid.requestMultiple(
[PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,PermissionsAndroid.PERMISSIONS.RECORD_AUDIO],
{
title: "Audio Recording Permission",
message:"PERSMISSION RO RECORD AUDIO",
buttonNeutral: "Ask Me Later",
buttonNegative: "Cancel",
buttonPositive: "OK"
}
);
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
console.log("You can use the camera");
} else {
console.log("Camera permission denied");
}
} catch (err) {
console.warn(err);
}
};
start =async () => {
console.log('start record');
this.setState({ audioFile: '', recording: true, loaded: false });
AudioRecord.start();
};
stop = async () => {
if (!this.state.recording) return;
console.log('stop record');
try{
var audioFile = await AudioRecord.stop();
}
catch(err){
console.warn(err);
}
console.log('audioFile', audioFile);
this.setState({ audioFile, recording: false });
};
load = () => {
return new Promise((resolve, reject) => {
if (!this.state.audioFile) {
}
this.sound = new Sound(this.state.audioFile, '', error => {
});
});
};
play = async () => {
if (!this.state.loaded) {
try {
} catch (error) {
}
}
this.setState({ paused: false });
Sound.setCategory('Playback');
this.sound.play(success => {
if (success) {
} else {
}
this.setState({ paused: true });
// this.sound.release();
});
};
pause = () => {
this.sound.pause();
this.setState({ paused: true });
};
render() {
const { recording, paused, audioFile } = this.state;
return (
);
}
import:-
import {
Header,
LearnMoreLinks,
Colors,
DebugInstructions,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
import React, { Component, useState,useEffect } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
Button,
TextInput,
TouchableHighlight,
Platform,
PermissionsAndroid,
} from 'react-native';
import {AudioRecord} from 'react-native-audio-record';
import Sound from 'react-native-sound';
// We are importing the native Java module here
import { Buffer } from 'buffer';
import {NativeModules} from 'react-native';
import RadioForm, {RadioButton, RadioButtonInput, RadioButtonLabel} from 'react-native-simple-radio-button';
Could someone look into this issue and provide possible fix?
The text was updated successfully, but these errors were encountered: