User Tools

Site Tools


informatica:speech_to_text

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
informatica:speech_to_text [2023/03/21 14:28] joseinformatica:speech_to_text [2023/03/21 16:31] jose
Line 48: Line 48:
 </code> </code>
  
 +Se envía un audio con este comando y te devuelve el texto:
 +  curl -X POST -F 'audio=@a.ogg' http://10.103.0.1:3000/transcribir
 +
 +====== Servicio de Google ======
 +<code>
 +import speech_recognition as sr
 +import time
 +
 +# Creamos un objeto Recognizer
 +r = sr.Recognizer()
 +
 +# Abrimos el archivo de audio y lo pasamos al objeto AudioFile
 +with sr.AudioFile('audio.wav') as source:
 +    # Leemos el audio del archivo
 +    audio = r.record(source)
 +
 +# Convertimos el audio a texto
 +text = r.recognize_google(audio, language='es-ES')
 +
 +# Generamos un nombre de archivo único para el texto
 +filename = 'texto_' + str(int(time.time())) + '.txt'
 +
 +# Guardamos el texto en un archivo de texto
 +with open(filename, 'w') as f:
 +    f.write(text)
 +</code>
informatica/speech_to_text.txt · Last modified: 2023/04/14 08:31 by jose