Desde OS X 10.5, OS X se ha incluido con el puente PyObjC, un puente Python-Objective-C. Utiliza el marco BridgeSupport para mapear frameworks Objective-C a Python. A diferencia, MacRuby, PyObjC es un puente clásico: hay un objeto proxy en el lado python para cada objeto ObjC y viceversa. Sin embargo, el puente es bastante fluido y es posible escribir aplicaciones completas en PyObjC (Xcode tiene soporte básico de PyObjC, y puedes descargar la aplicación y las plantillas de archivos para Xcode desde el SVN de PyObjC en el enlace de arriba). Mucha gente lo usa para utilidades o para aplicaciones/scripts/complementos. El sitio para desarrolladores de Apple también tiene un introduction para desarrollar aplicaciones Cocoa con Python a través de PyObjC, que está un poco desactualizado, pero puede ser una buena visión general para usted.
En su caso, el siguiente código llamará [NSSpeechSynthesizer availableVoices]
:
from AppKit import NSSpeechSynthesizer
NSSpeechSynthesizer.availableVoices()
que devuelve
(
"com.apple.speech.synthesis.voice.Agnes",
"com.apple.speech.synthesis.voice.Albert",
"com.apple.speech.synthesis.voice.Alex",
"com.apple.speech.synthesis.voice.BadNews",
"com.apple.speech.synthesis.voice.Bahh",
"com.apple.speech.synthesis.voice.Bells",
"com.apple.speech.synthesis.voice.Boing",
"com.apple.speech.synthesis.voice.Bruce",
"com.apple.speech.synthesis.voice.Bubbles",
"com.apple.speech.synthesis.voice.Cellos",
"com.apple.speech.synthesis.voice.Deranged",
"com.apple.speech.synthesis.voice.Fred",
"com.apple.speech.synthesis.voice.GoodNews",
"com.apple.speech.synthesis.voice.Hysterical",
"com.apple.speech.synthesis.voice.Junior",
"com.apple.speech.synthesis.voice.Kathy",
"com.apple.speech.synthesis.voice.Organ",
"com.apple.speech.synthesis.voice.Princess",
"com.apple.speech.synthesis.voice.Ralph",
"com.apple.speech.synthesis.voice.Trinoids",
"com.apple.speech.synthesis.voice.Vicki",
"com.apple.speech.synthesis.voice.Victoria",
"com.apple.speech.synthesis.voice.Whisper",
"com.apple.speech.synthesis.voice.Zarvox"
)
(NSCFArray un puente) en mi máquina SL.
+1 por ejemplo. –
No necesita importar el módulo objc, solo Foundation. –
Hah, tienes razón. Actualizaré mi ejemplo. – Benno