informatica:speech_to_text
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| informatica:speech_to_text [2023/03/21 14:34] – jose | informatica:speech_to_text [2023/04/14 08:31] (current) – jose | ||
|---|---|---|---|
| Line 50: | Line 50: | ||
| Se envía un audio con este comando y te devuelve el texto: | Se envía un audio con este comando y te devuelve el texto: | ||
| curl -X POST -F ' | curl -X POST -F ' | ||
| + | |||
| + | ====== Servicio de Google ====== | ||
| + | < | ||
| + | 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(' | ||
| + | # Leemos el audio del archivo | ||
| + | audio = r.record(source) | ||
| + | |||
| + | # Convertimos el audio a texto | ||
| + | text = r.recognize_google(audio, | ||
| + | |||
| + | # Generamos un nombre de archivo único para el texto | ||
| + | filename = ' | ||
| + | |||
| + | # Guardamos el texto en un archivo de texto | ||
| + | with open(filename, | ||
| + | f.write(text) | ||
| + | </ | ||
| + | |||
| + | ====== API TELEGRAM ====== | ||
| + | / | ||
| + | |||
| + | Graba el archivo en el file system como AwAxxxxxxxx.ogg | ||
| + | |||
| + | Lo pasa a http:// | ||
informatica/speech_to_text.1679409276.txt.gz · Last modified: by jose
