[mary-users] HalfphoneFeatureComputer

Jerome Perri jerome.perri at hotmail.com
Wed Sep 7 18:40:08 CEST 2011


Wow, you are so good. Thank you.
Making that change was easy... So far it looks good, but I am not finished yet with my voice building procedure :-)


> Date: Wed, 7 Sep 2011 18:52:18 +0400
> Subject: Re: [mary-users] HalfphoneFeatureComputer
> From: nshmyrev at nexiwave.com
> To: jerome.perri at hotmail.com
> CC: fxavier at ircam.fr; marc.schroeder at dfki.de; mary-users at dfki.de; ingmar.steiner at inria.fr
> 
> Looks like you need to change the source code and make
> HalfPhoneFeatureProcess an implementation of
> ShortValuedFeatureProcessor not ByteValuedFeatureProcessor as it is
> now since you have too many phones it just gets out of range.
> 
> On Wed, Sep 7, 2011 at 6:49 PM, Jerome Perri <jerome.perri at hotmail.com> wrote:
> > And to be even more specific:
> > I think the error (if it should be one) occurs here in the 3rd line from
> > below ("map.put..."):
> >
> >     /**
> >      * Initialize a byte-string two-way translator,
> >      * setting byte values according to the position of strings
> >      * in the array.
> >      * @param strings a list of up to {@link #MAXNUM} strings to be
> > represented by unique byte values.
> >      * @throws IllegalArgumentException if list of strings is longer than
> > the maximum number of values, {@link #MAXNUM}.
> >      */
> >     public ByteStringTranslator(String[] strings)
> >     {
> >         if (strings.length > MAXNUM) {
> >             StringBuilder buf = new StringBuilder();
> >             for (int i=0; i<strings.length; i++) {
> >                 buf.append("\""+strings[i]+"\" ");
> >             }
> >             throw new IllegalArgumentException("Too many strings for a
> > byte-string translator: \n"+buf.toString()+ "("+strings.length+" strings)");
> >         }
> >         list = new ArrayList<String>(Arrays.asList(strings));
> >         map = new HashMap<String, Byte>();
> >         for (int i=0; i<strings.length; i++) {
> >             map.put(strings[i], (byte)i); //HERE NEGATIVE BYTE VALUES ARE
> > GIVEN TO THE HALFPHONEUNITNAMES
> >         }
> >     }
> >
> > ________________________________
> > From: jerome.perri at hotmail.com
> > To: nshmyrev at nexiwave.com; mary-users at dfki.de; marc.schroeder at dfki.de;
> > fxavier at ircam.fr
> > Subject: [mary-users] HalfphoneFeatureComputer
> > Date: Wed, 7 Sep 2011 16:39:49 +0200
> >
> > Hello all,
> >
> > I would like to start my question from scratch, please:
> >
> > I have now found out more about why the HalfPhoneFeatureComputer does not
> > want to work.
> >
> > I have over 70 phonemes in my phonemeset.
> > When I query certain HalfPhoneUnitName names as ByteFeatures, I get negative
> > values, and in one place I think a positive value is expected.
> >
> > For example if I take a look at the HalfPhoneUnitProcessor in IDE, the byte
> > representation for "y:_L" is -113.
> >
> > This negative value is given to the HalfPhoneUnit in this step:
> >
> >         public HalfPhoneUnitName(String[] possiblePhonemes, String
> > pauseSymbol)
> >         {
> >             this.name = "halfphone_unitname";
> >             this.pauseSymbol = pauseSymbol;
> >             String[] possibleValues = new
> > String[2*possiblePhonemes.length+1];
> >             possibleValues[0] = "0"; // the "n/a" value
> >             for (int i=0; i<possiblePhonemes.length; i++) {
> >                 possibleValues[2*i+1] = possiblePhonemes[i]+"_L";
> >                 possibleValues[2*i+2] = possiblePhonemes[i]+"_R";
> >             }
> >             this.values = new ByteStringTranslator(possibleValues);//HERE
> > THE NEGATIVE VALUES ARE GIVEN FOR SOME HALFPHONES
> >         }
> > ----
> > And here is where the error then finally hits and make the
> > HalfPhoneFeatureComputer fail (I have added a separate error handler here):
> >
> >     /**
> >      * For the given elements and using the given feature computer, create a
> > string representation of the
> >      * target features.
> >      * @param featureComputer
> >      * @param segmentsAndBoundaries
> >      * @return a multi-line string.
> >      * @throws Exception
> >      */
> >     public String listTargetFeatures(TargetFeatureComputer featureComputer,
> > List<Element> segmentsAndBoundaries) throws Exception
> >     {
> >
> >         try {
> >         String pauseSymbol = featureComputer.getPauseSymbol();
> >         List<Target> targets =
> > overridableCreateTargetsWithPauses(segmentsAndBoundaries, pauseSymbol);
> >         // Third, compute the feature vectors and convert them to text
> >         String header =
> > featureComputer.getAllFeatureProcessorNamesAndValues();
> >         StringBuilder text = new StringBuilder();
> >         StringBuilder bin = new StringBuilder();
> >         for (Target target : targets) {
> >             //System.err.print("target name " + target.getName());
> >             String sTargetName;
> >             sTargetName=target.getName();
> >             if (target.getName().equals("y:_L"))
> >             {
> >                     int bla;
> >                     bla=0; // I have set a breakpoint here to track the
> > following in detail
> >             }
> >             FeatureVector features =
> > featureComputer.computeFeatureVector(target);
> >
> > text.append(featureComputer.toStringValues(features)).append("\n");//hier
> > kommt der fehler
> >             bin.append(features.toString()).append("\n");
> >         }
> >
> >         // Leave an empty line between sections:
> >         String out = header + "\n" + text + "\n" + bin;
> >         return out;
> >         } catch (Exception e) {
> >             throw new Exception("Doh!", e);
> >         }
> >     }
> >
> > The error occurs in text.append(featureComputer ...).
> > ----
> > The underlying calls are
> >
> > /**
> >      * Using the set of feature processors defined when creating the target
> > feature computer,
> >      * compute a feature vector for the target
> >      * @param target
> >      * @return a feature vector for the target
> >      */
> >     public FeatureVector computeFeatureVector(Target target)
> >     {
> >         byte[] byteFeatures = new
> > byte[byteValuedDiscreteFeatureProcessors.length];
> >         short[] shortFeatures = new
> > short[shortValuedDiscreteFeatureProcessors.length];
> >         float[] floatFeatures = new
> > float[continuousFeatureProcessors.length];
> >         for (int i=0; i<byteValuedDiscreteFeatureProcessors.length; i++) {
> >             byteFeatures[i] =
> > byteValuedDiscreteFeatureProcessors[i].process(target);//HERE THE ERROR
> > OCCURS
> >         }
> >         for (int i=0; i<shortValuedDiscreteFeatureProcessors.length; i++) {
> >             shortFeatures[i] =
> > shortValuedDiscreteFeatureProcessors[i].process(target);
> >         }
> >         for (int i=0; i<continuousFeatureProcessors.length; i++) {
> >             floatFeatures[i] =
> > continuousFeatureProcessors[i].process(target);
> >         }
> >         return new FeatureVector(byteFeatures, shortFeatures, floatFeatures,
> > 0);
> >     }
> > ---
> > TargetFeatureComputer
> >
> >   /**
> >      * For the given feature vector, convert each encoded value into its
> > string representation.
> >      * @param features a feature vector, which must match the feature
> > processors known to this feature computer.
> >      * @return a string in which the string values of all features are
> > separated by spaces.
> >      * @throws IllegalArgumentException if the number of byte-valued,
> > short-valued or continuous elements in features
> >      * do not match the set of feature processors in this feature computer.
> >      */
> >     public String toStringValues(FeatureVector features)
> >     {
> >         StringBuilder buf = new StringBuilder();
> >         byte[] bytes = features.getByteValuedDiscreteFeatures();
> >         short[] shorts = features.getShortValuedDiscreteFeatures();
> >         float[] floats = features.getContinuousFeatures();
> >         if (bytes.length != byteValuedDiscreteFeatureProcessors.length
> >                 || shorts.length !=
> > shortValuedDiscreteFeatureProcessors.length
> >                 || floats.length != continuousFeatureProcessors.length) {
> >             throw new IllegalArgumentException("Number of features in
> > argument does not match number of feature processors");
> >         }
> >         for (int i=0; i<bytes.length; i++) {
> >             if (buf.length() > 0) buf.append(" ");
> >
> > buf.append(byteValuedDiscreteFeatureProcessors[i].getValues()[(int)bytes[i]]);
> > //HERE THE ERROR FINALLY OCCURS, I THINK IT WANTS A POSITIVE VALUE, BUT I
> > HAVE NEGATIVE
> >         }
> >         for (int i=0; i<shorts.length; i++) {
> >             if (buf.length() > 0) buf.append(" ");
> >
> > buf.append(shortValuedDiscreteFeatureProcessors[i].getValues()[(int)shorts[i]]);
> >         }
> >         for (int i=0; i<floats.length; i++) {
> >             if (buf.length() > 0) buf.append(" ");
> >             buf.append(floats[i]);
> >         }
> >         return buf.toString();
> >     }
> >
> > -----
> > MaryLanguageFeatureProcessor.HalfPhoneUnitName.getValues
> >
> > Was that informative and good? :-)
> >
> > Jerome
> >
> >
> >
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.dfki.de/pipermail/mary-users/attachments/20110907/0727c2b8/attachment-0001.htm 


More information about the Mary-users mailing list