1

I have the following program that is trying to pronounce a line of Danish text. I can't figure out why it is pronouncing it wrong. It should sound like "po so mo fo po", but it doesn't sound at all like that. It sounds more like "p n s n m n f n p n". I am using the Danish voice "Magnus" so it should know how to pronounce these. Also, when I use OSX Voice Over to pronounce the words it sounds right.

#!/usr/bin/env python
# -*- coding: utf-8 -*- 

from  AppKit import NSSpeechSynthesizer
import time
import sys

nssp = NSSpeechSynthesizer
ve = nssp.alloc().init()

from_voice = "com.apple.speech.synthesis.voice.magnus.premium"

line = "på så må få på"

ve.setVoice_(from_voice)
ve.startSpeakingString_(line)
time.sleep(1)

while ve.isSpeaking():
   time.sleep(1)

1 Answer 1

2

You need to pass in a unicode object, not a UTF-8 bytestring:

ve.startSpeakingString_(line.decode('utf8'))

You could define the line value as a Unicode literal instead of decoding:

line = u"på så må få på"
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.