import { Picker } from '@react-native-picker/picker'; import * as Speech from 'expo-speech'; import * as React from 'react'; import { Button, Platform, ScrollView, StyleSheet, Text, TouchableOpacity, View, } from 'react-native'; import HeadingText from '../components/HeadingText'; import { Colors } from '../constants'; const EXAMPLES = [ { language: 'en', text: 'Hello world' }, { language: 'es', text: 'Hola mundo' }, { language: 'en', text: 'Charlie Cheever chased a chortling choosy child' }, { language: 'en', text: 'Adam Perry ate a pear in pairs in Paris' }, ]; const AmountControlButton: React.FunctionComponent< React.ComponentProps & { title: string; } > = (props) => ( {props.title} ); interface State { selectedExample: { language: string; text: string }; inProgress: boolean; paused: boolean; pitch: number; rate: number; voiceList?: { name: string; identifier: string }[]; voice?: string; } // See: https://github.com/expo/expo/pull/10229#discussion_r490961694 // eslint-disable-next-line @typescript-eslint/ban-types export default class TextToSpeechScreen extends React.Component<{}, State> { static navigationOptions = { title: 'Speech', }; readonly state: State = { selectedExample: EXAMPLES[0], inProgress: false, paused: false, pitch: 1, rate: 0.75, }; async componentDidMount() { if (Platform.OS === 'ios') { await this._loadAllVoices(); } } render() { return ( Select a phrase {EXAMPLES.map(this._renderExample)}