Currently, I am doing a project to do a tts(Text to Speech) by using AI mimic voice. I was able to make a tts program by using python, but I don't know how to connect it with my application.
This is my github code https://github.com/2021-2-HYU-AI/front-end
This is the java code to send a message.
import React, { useState, useCallback } from 'react';
import { View, Text, Dimensions, TouchableOpacity, StyleSheet } from 'react-native';
import { GiftedChat } from 'react-native-gifted-chat';
import { AntDesign } from '@expo/vector-icons';
const {height, width} = Dimensions.get("window")
function Chat({navigation: {goBack}}) {
const [messages, setMessages] = useState([]);
const onSend = useCallback((messages = []) => {
// console.log('previousMessages: ',previousMessages)
console.log('messages: ', messages)
setMessages(previousMessages => GiftedChat.append(previousMessages, messages))
}, [])
return (
<View style={{ flex: 1}}>
<View style={styles.header}>
<TouchableOpacity onPress={() => goBack()}>
<AntDesign name="left" size={24} color="black" />
</TouchableOpacity>
<Text style={styles.headerText}>메세지 남기기</Text>
</View>
<GiftedChat
placeholder={'메세지를 입력하세요...'}
alwaysShowSend={true}
messages={messages}
textInputProps={{ keyboardAppearance: 'dark', autoCorrect: false }}
onSend={messages => onSend(messages)}
user={{
_id: 1,
}}
/>
</View>
)
}
const styles = StyleSheet.create({
header: {
flex: 0.1,
alignItems: "center",
flexDirection: "row",
paddingHorizontal: 10,
borderBottomColor: "black",
borderBottomWidth: 1,
},
headerText: {
fontSize: 20,
fontWeight: "500",
marginLeft: 5,
}
});
and this is the python code that I am making.
import requests
import os
path=os.getcwd()
print(path)
def download(url, file_name):
with open(file_name,"wb") as file:
response=requests.get(url)
file.write(response.content)
if __name__=='__main__':
text=input('메시지 입력 : ')
url="http://localhost:5000/tts-server/api/infer-glowtts?text="+text
download(url, "TTS.mp3")
and this is the python code that I want to connect it.
chat.js If I type the message I want the text message to go to the python to text=input
part and do the tts automatically. Thank you for reading my post.
You should create an open API for this to work
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.