I am using GoogleTrans for my project. Actually I have a text in Marathi which I got from "speech to text" but when I am converting that text into English it is not translating properLY.
But when I am using Google Translate from website, it is translating properly with 100% accuracy ?
Here is the piece of Code :
import speech_recognition as sr
from cltk.corpus.utils.importer import CorpusImporter
from googletrans import Translator
import goslate
import googletrans
print("Hello World")
filename = r"C:UsersTOSHIBADocumentsMini Project-2 (Trimester 4)Project 1- (Document Summary)DatasetVoiceGaurav.wav"
r = sr.Recognizer()
with sr.AudioFile(filename) as source:
audio_data = r.record(source)
text = r.recognize_google(audio_data,language='mr')
print("Text
",text)
print(type(text))
translator = Translator()
converted_text = translator.translate(text)
print("Converted text
",converted_text)
with open("D:/output.txt",'w',encoding="utf-8") as f:
f.write(text)
f.write(str(converted_text))
Please suggest, what should I do?
See Question&Answers more detail:os