@@ -16,6 +16,7 @@ public abstract class LatinDiphonePhonemizer : Phonemizer {
1616 protected IG2p g2p ;
1717 protected bool isDictionaryLoading ;
1818
19+ //[(index of phoneme, tick position from the lyrical note in notes[], is manual)]
1920 protected readonly List < Tuple < int , int , bool > > alignments = new List < Tuple < int , int , bool > > ( ) ;
2021
2122 /// <summary>
@@ -89,14 +90,14 @@ public override Result Process(Note[] notes, Note? prev, Note? next, Note? prevN
8990 // - Tries to align every note to one syllable.
9091 // - "+n" manually aligns to n-th phoneme.
9192 alignments . Clear ( ) ;
92- int position = 0 ;
93+ //notes except those whose lyrics start witn "+*" or "+~"
94+ var nonExtensionNotes = notes . Where ( n=> ! IsSyllableVowelExtensionNote ( n ) ) . ToArray ( ) ;
9395 for ( int i = 0 ; i < symbols . Length ; i ++ ) {
94- if ( isVowel [ i ] && alignments . Count < notes . Length ) {
95- alignments . Add ( Tuple . Create ( i , position , false ) ) ;
96- position += notes [ alignments . Count - 1 ] . duration ;
96+ if ( isVowel [ i ] && alignments . Count < nonExtensionNotes . Length ) {
97+ alignments . Add ( Tuple . Create ( i , nonExtensionNotes [ alignments . Count ] . position - notes [ 0 ] . position , false ) ) ;
9798 }
9899 }
99- position = notes [ 0 ] . duration ;
100+ int position = notes [ 0 ] . duration ;
100101 for ( int i = 1 ; i < notes . Length ; ++ i ) {
101102 if ( int . TryParse ( notes [ i ] . lyric . Substring ( 1 ) , out var idx ) ) {
102103 alignments . Add ( Tuple . Create ( idx - 1 , position , true ) ) ;
@@ -154,6 +155,15 @@ public override Result Process(Note[] notes, Note? prev, Note? next, Note? prevN
154155 } ;
155156 }
156157
158+ /// <summary>
159+ /// Does this note extend the previous syllable?
160+ /// </summary>
161+ /// <param name="note"></param>
162+ /// <returns></returns>
163+ protected bool IsSyllableVowelExtensionNote ( Note note ) {
164+ return note . lyric . StartsWith ( "+~" ) || note . lyric . StartsWith ( "+*" ) ;
165+ }
166+
157167 string [ ] GetSymbols ( Note note ) {
158168 if ( string . IsNullOrEmpty ( note . phoneticHint ) ) {
159169 // User has not provided hint, query CMUdict.
0 commit comments