Ver Mensaje Individual
  #1  
Antiguo 12-08-2025
juank1971 juank1971 is offline
Miembro
 
Registrado: feb 2008
Posts: 241
Reputación: 19
juank1971 Va por buen camino
python4delphi

Hola tengo este script en python :

Código:
# voz_module.py
import speech_recognition as sr
import json

def reconocer_voz():
    """
    Retorna un JSON con:
    { "texto": "hola", "error": "" }
    """
    r = sr.Recognizer()
    r.pause_threshold = 2.5

    try:
        with sr.Microphone() as source:
            audio = r.listen(source, timeout=10, phrase_time_limit=20)
        texto = r.recognize_google(audio, language="es-ES")
        return json.dumps({"texto": texto, "error": ""})
    except sr.WaitTimeoutError:
        return json.dumps({"texto": "", "error": "NO_VOZ"})
    except sr.UnknownValueError:
        return json.dumps({"texto": "", "error": "NO_ENTENDIDO"})
    except sr.RequestError:
        return json.dumps({"texto": "", "error": "ERROR_RED"})
    except Exception as e:
        return json.dumps({"texto": "", "error": "EXCEPCION"})

# Para pruebas locales
if __name__ == "__main__":
    print(reconocer_voz())
quisiera ejecutralo en python4delphi desde delphi 12.3 pero que cuando distribulla la aplicacion .exe el cliente no tenga que tener instalado el python esto es posible ?

Última edición por Casimiro Noteví fecha: 13-08-2025 a las 09:39:34.
Responder Con Cita