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

Can Chatterbot speak Turkish? #20

Open
UfukGuler34 opened this issue Dec 25, 2018 · 0 comments
Open

Can Chatterbot speak Turkish? #20

UfukGuler34 opened this issue Dec 25, 2018 · 0 comments

Comments

@UfukGuler34
Copy link

UfukGuler34 commented Dec 25, 2018

In this days my friends are trying to create a robot that could look the person that in front of him than listen him. My job began in here. I have to create a chat bot that listen the person with mic than recognize what he/she says after that answer him.
Now my program can listen people and recognize the words. But my program can answer in English. Because i am Turkish i have make it in Turkish.
Is there anybody in there to help me?
This is all i got for now.

from gtts import gTTS
import os
import speech_recognition as sr
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
chatbot = ChatBot("Ron Obvious")

"""
conversation = [
"merhaba",
"sana da merhaba",
"ne haber",
"iyidir senden",
"kac yasindasin",
"18 yasindayim",
"ismin ne ",
"benim adim aytek",
"hava nasil",
"iyi bea nasil olsun"
]
"""

conversation = open('chats.txt','r').readlines()
chatbot.set_trainer(ListTrainer)
chatbot.train(conversation)

def konusma(metin):
tts= gTTS(text=metin ,lang='tr')
tts.save("aaa.mp3")
os.system("mpg321 aaa.mp3")

r= sr.Recognizer()

with sr.Microphone() as kaynak:
print("Please wait. Calibrating microphone...")
# listen for 5 seconds and calculate the ambient noise energy level
r.adjust_for_ambient_noise(kaynak, duration=5)
konusma('kalibre tamamlandi')

while True:
with sr.Microphone() as kaynak:
ses = r.listen(kaynak,timeout = None)
try:
print(r.recognize_google(ses,language="tr-TR"))
soru=r.recognize_google(ses,language="tr-TR")
response = chatbot.get_response(soru)
print(response)
konusma(str(response))
except sr.UnknownValueError:
print("Anlamadim.")
except sr.RequestError:
print("Bad Request")

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

1 participant