-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.py
44 lines (33 loc) · 1.17 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# -*- coding:utf-8 -*-
import os
from utils import recorder
from utils import aibril_module
from utils import speech_to_text
from utils import text_to_speech
from utils import audio_converter
from utils import media_player
if __name__ == '__main__':
aibril_conn = aibril_module.WatsonServer()
stt_conn = speech_to_text.SpeechToText()
tts_conn = text_to_speech.TextToSpeech()
# while True:
recording_file = recorder.start_record()
transcript = stt_conn.audio_stt(recording_file)
answer = aibril_conn.aibril_conv(transcript)
# output_gtts = tts_conn.google_tts(answer)
# output_ntts = tts_conn.naver_tts(answer)
output_atts = tts_conn.aws_tts(answer)
# convert_audio = audio_converter.convert(output_gtts)
# convert_audio = audio_converter.convert(output_ntts)
convert_audio = audio_converter.convert(output_atts)
os.system('aplay ' + convert_audio)
mp = media_player.media_player(transcript)
print(mp)
try:
if mp[-3:] == 'mp3':
convert_audio = audio_converter.convert(mp)
os.system('aplay ' + convert_audio + ' &')
else:
pass
except Exception as e:
pass