Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inconsistent audio in twilio say verbs. #153

Closed
Thagana opened this issue May 13, 2020 · 1 comment
Closed

inconsistent audio in twilio say verbs. #153

Thagana opened this issue May 13, 2020 · 1 comment

Comments

@Thagana
Copy link

Thagana commented May 13, 2020

Hello

I am getting different twilio say verbs, sometimes it finishes saying the options sometimes it it stops saying halfway and sometimes it does not say the first option.I need the user to hear all the options from the say verb but half way the audio mutes. not saying the other options.

here is my code below

import React, { Component } from 'react';
import {
	Platform,
	StyleSheet,
	Text,
	View,
	TouchableOpacity,
	PermissionsAndroid,
} from 'react-native';
import TwilioVoice from 'react-native-twilio-programmable-voice';

export default class App extends Component {
	state = {
		twilioInited: false,
	};

	getAuthToken = () => {
		return fetch('endpoint', {
			// replace c2a19b17.ngrok.io with your link (from Step 1)
			method: 'get',
		})
			.then((response) => response.text())
			.catch((error) => console.error(error));
	};

	getMicrophonePermission = () => {
		const audioPermission = PermissionsAndroid.PERMISSIONS.RECORD_AUDIO;

		return PermissionsAndroid.check(audioPermission).then(async (result) => {
			if (!result) {
				const granted = await PermissionsAndroid.request(audioPermission, {
					title: 'Microphone Permission',
					message:
						'App needs access to you microphone ' +
						'so you can talk with other users.',
				});
			}
		});
	};

	initTwilio = async () => {
		const token = await this.getAuthToken();

		if (Platform.OS === 'android') {
			await this.getMicrophonePermission();
		}
		const res = await TwilioVoice.initWithToken(token);
		console.log(res);
		TwilioVoice.addEventListener('deviceReady', () => {});
		if (res.initialized) {
			this.setState({ twilioInited: true });
		}
		if (Platform.OS === 'ios') {
			// required for ios
			TwilioVoice.configureCallKit({
				appName: 'ReactNativeTwilioExampleApp',
			});
		}
	};

	makeCall = () => TwilioVoice.connect({ To: '+1234567890' });

	render() {
		return (
			<View style={styles.container}>
				<TouchableOpacity onPress={() => this.initTwilio()}>
					<View>
						<Text>Init Twilio</Text>
					</View>
				</TouchableOpacity>
				<TouchableOpacity
					disabled={!this.state.twilioInited}
					onPress={() => this.makeCall()}
				>
					<View>
						<Text>
							Make call ({this.state.twilioInited ? 'ready' : 'not ready'}
)
						</Text>
					</View>
				</TouchableOpacity>
			</View>
		);
	}
}

const styles = StyleSheet.create({
	container: {
		flex: 1,
		justifyContent: 'center',
		alignItems: 'center',
		backgroundColor: '#F5FCFF',
	},
});

thanks in advance

@jdegger
Copy link
Collaborator

jdegger commented Oct 27, 2020

I recommend adding a in your Twiml. We see the same and seems more like a Twilio issue than an issue with this library.

Since a long time has passed I will be closing this issue. Read our repository update in #158. I invite you to reopen this issue when you still have problems so we can debug the problems together.

@jdegger jdegger closed this as completed Oct 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants