File tree Expand file tree Collapse file tree 3 files changed +26
-27
lines changed
Expand file tree Collapse file tree 3 files changed +26
-27
lines changed Original file line number Diff line number Diff line change @@ -27,13 +27,16 @@ if (store.enginePath != undefined) {
2727 store . enginePath = undefined ;
2828 } else {
2929 console . log ( `Starting the engine at ${ store . enginePath } ...` ) ;
30- new Deno . Command (
30+ const process = new Deno . Command (
3131 store . enginePath ,
3232 {
3333 stdout : "inherit" ,
3434 stderr : "inherit" ,
3535 } ,
3636 ) . spawn ( ) ;
37+ self . addEventListener ( "unload" , ( ) => {
38+ process . kill ( ) ;
39+ } ) ;
3740 }
3841} else {
3942 console . log ( "No engine path, not starting the engine." ) ;
Original file line number Diff line number Diff line change @@ -83,38 +83,33 @@ const prosodyToAccentPhrases = (prosody: Prosody) => {
8383const accentPhrasesToProsody = ( accentPhrases : AccentPhrase [ ] ) => {
8484 return accentPhrases . map ( ( accentPhrase ) => {
8585 const detail = [ ] ;
86- let hasPause = false ;
8786
8887 accentPhrase . moras . forEach ( ( mora , i ) => {
89- if ( mora . text === "、" ) {
90- hasPause = true ;
88+ let phoneme ;
89+ if ( mora . consonant && mora . consonant . length > 0 ) {
90+ phoneme = `${ mora . consonant } -${ mora . vowel } ` ;
9191 } else {
92- let phoneme ;
93- if ( mora . consonant && mora . consonant . length > 0 ) {
94- phoneme = `${ mora . consonant } -${ mora . vowel } ` ;
95- } else {
96- phoneme = mora . vowel ;
97- }
98-
99- let accent = 0 ;
100- if (
101- i === accentPhrase . accent - 1 ||
102- ( i !== 0 && i <= accentPhrase . accent - 1 )
103- ) {
104- accent = 1 ;
105- }
92+ phoneme = mora . vowel ;
93+ }
10694
107- detail . push ( {
108- hira : wanakana . toHiragana (
109- mora . text ,
110- ) ,
111- phoneme,
112- accent,
113- } ) ;
95+ let accent = 0 ;
96+ if (
97+ i === accentPhrase . accent - 1 ||
98+ ( i !== 0 && i <= accentPhrase . accent - 1 )
99+ ) {
100+ accent = 1 ;
114101 }
102+
103+ detail . push ( {
104+ hira : wanakana . toHiragana (
105+ mora . text ,
106+ ) ,
107+ phoneme,
108+ accent,
109+ } ) ;
115110 } ) ;
116111
117- if ( hasPause ) {
112+ if ( accentPhrase . pause_mora ) {
118113 detail . push ( {
119114 hira : "、" ,
120115 phoneme : "_" ,
Original file line number Diff line number Diff line change @@ -45,5 +45,6 @@ export const getOrAppendSpeaker = async (
4545} ;
4646
4747export const saveStore = async ( ) => {
48- await Deno . writeTextFile ( filePath , JSON . stringify ( store ) ) ;
48+ await Deno . writeTextFile ( filePath + ".tmp" , JSON . stringify ( store ) ) ;
49+ await Deno . rename ( filePath + ".tmp" , filePath ) ;
4950} ;
You can’t perform that action at this time.
0 commit comments