0
I’m making a system with Speech Recognition where as I speak it goes saving in a file . db (or .txt) but I noticed that the following characters appear when I speak a word with special characters like ç:
Would anyone know the reason for this and how to resolve it? I have tried to find it in several places but found nothing in relation to it
Follows as it print on terminal and as saved on doc:
That’s the part of the code:
with SR.Microphone() as source:
winsound.Beep(1500, 250) # Recording
audio = r.listen(source)
winsound.Beep(500, 250) # End
with open(nm_song, 'wb') as song:
song.write(audio.get_wav_data())
try:
fala = r.recognize_google(audio, language="pt-BR")
print('Você disse: ' + r.recognize_google(audio, language="pt-BR"))
with open('C:\\Users\\User\\Desktop\\Bots\\Klo\\yk12mmkiy78.txt', 'a') as f:
f.write(fala + ';')
except SR.UnknownValueError:
_naoEntendi("Eu não entendi, poderia ser mais claro por favor?")
put the part of the code in which it saves in the file.
– Wictor Chaves
@Wictorchaves I edited with the code
– Erick Vieira
I believe your file has another character formatting. Try using the
encoding="utf-8"
to force accept the special characters in front of the'a'
to see if the problem persists.– user89389
@Murilochaves thank you very much, solved the problem!
– Erick Vieira
@Erickvieira have, formalized the answer below, if you want to validate it as useful. Thank you.
– user89389