Python nuube needs Unicode help
gheissenberger at gmail.com
gheissenberger at gmail.com
Fri Jan 12 10:31:32 EST 2007
Diez, you are awesome! This works! Thank you so much!!! You are so
awesome!
Diez B. Roggisch wrote:
> gheissenberger at gmail.com wrote:
>
> > Can you attach files in this forum? Couldn't find the option. Oh well,
> > here's the file.
> >
> > #!/usr/bin/python
> > # Version: 1.1
> > # Author: Steve Losh
> >
> > from sets import Set
> > from optparse import OptionParser
> > from xml.dom.minidom import parse
> >
> > AudioPath = 'audio/'
> > DatafilePath = 'utterances.trmxml'
> > CONFIDENCE_LOW = None #'500'
> > CONFIDENCE_HIGH = None #'500'
> >
> > utterancesFile = None
> >
> >
> > class Utterance:
> > def __init__(self, audio, grammarSet, text):
> > self.audio = audio
> > self.grammarSet = grammarSet
> > self.text = text
> >
> > def __str__(self):
> > return "SWIrecAcousticStateReset\ntranscription " + self.text \
> > + "\nrecognize " + AudioPath + self.audio
>
> There your __str__-method is. self.text and self.audio come from the
> xml-parsing and are unicode objects - so they need to be encoded, like
> this:
>
> def __str__(self):
> return "SWIrecAcousticStateReset\ntranscription " +
> self.text.encode('utf-8') + "\nrecognize " + AudioPath +
> self.audio.encode('utf-8')
>
>
> Diez
More information about the Python-list
mailing list