Skip to content

Instantly share code, notes, and snippets.

@tgck
Created August 20, 2012 16:24
Show Gist options
  • Save tgck/3405500 to your computer and use it in GitHub Desktop.
Save tgck/3405500 to your computer and use it in GitHub Desktop.
simpleSpeakSynthesizer2
# every time another person speaks!
from AppKit import NSSpeechSynthesizer
import random
voices = NSSpeechSynthesizer.availableVoices()
voices = [x.split(".")[-1] for x in voices]
def speak(txt):
voice = "com.apple.speech.synthesis.voice." + voices[random.randint(0,len(voices))]
speech = NSSpeechSynthesizer.alloc().initWithVoice_(voice)
speech.startSpeakingString_(txt);
speak("Helloooooooooooooooooooo!!!!");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment