1
1
import path from "path" ;
2
2
import { v4 as uuidv4 } from "uuid" ;
3
3
import Encoding from "encoding-japanese" ;
4
- import { toRaw } from "vue" ;
5
4
import { createUILockAction , withProgress } from "./ui" ;
6
5
import {
7
6
AudioItem ,
@@ -26,7 +25,6 @@ import {
26
25
sanitizeFileName ,
27
26
DEFAULT_STYLE_NAME ,
28
27
formatCharacterStyleName ,
29
- joinTextsInAccentPhrases ,
30
28
TuningTranscription ,
31
29
} from "./utility" ;
32
30
import { convertAudioQueryFromEditorToEngine } from "./proxy" ;
@@ -133,7 +131,7 @@ function parseTextFile(
133
131
if ( lastVoice == undefined ) throw new Error ( `lastStyle is undefined.` ) ;
134
132
for ( const splitText of body . split ( new RegExp ( `${ seps . join ( "|" ) } ` , "g" ) ) ) {
135
133
const voice = name2Voice . get ( splitText ) ;
136
- if ( voice !== undefined ) {
134
+ if ( voice != undefined ) {
137
135
lastVoice = voice ;
138
136
continue ;
139
137
}
@@ -413,7 +411,7 @@ export const audioStore = createPartialStore<AudioStoreTypes>({
413
411
Object . entries ( rawMorphableTargets ) . map ( ( [ key , value ] ) => {
414
412
const isMorphable = ( value as unknown as { is_morphable : boolean } )
415
413
. is_morphable ;
416
- if ( isMorphable === undefined || typeof isMorphable !== "boolean" ) {
414
+ if ( isMorphable == undefined || typeof isMorphable !== "boolean" ) {
417
415
throw Error (
418
416
"The is_morphable property does not exist, it is either CamelCase or the engine type is wrong."
419
417
) ;
@@ -457,13 +455,13 @@ export const audioStore = createPartialStore<AudioStoreTypes>({
457
455
voice . engineId ,
458
456
voice . styleId
459
457
) ;
460
- if ( characterInfo === undefined )
461
- throw new Error ( "assert characterInfo !== undefined" ) ;
458
+ if ( characterInfo == undefined )
459
+ throw new Error ( "assert characterInfo != undefined" ) ;
462
460
463
461
const style = characterInfo . metas . styles . find (
464
462
( style ) => style . styleId === voice . styleId
465
463
) ;
466
- if ( style === undefined ) throw new Error ( "assert style != = undefined" ) ;
464
+ if ( style == undefined ) throw new Error ( "assert style != undefined" ) ;
467
465
468
466
const speakerName = characterInfo . metas . speakerName ;
469
467
const styleName = style . styleName ;
@@ -699,7 +697,7 @@ export const audioStore = createPartialStore<AudioStoreTypes>({
699
697
}
700
698
) {
701
699
const index =
702
- prevAudioKey !== undefined
700
+ prevAudioKey != undefined
703
701
? state . audioKeys . indexOf ( prevAudioKey ) + 1
704
702
: state . audioKeys . length ;
705
703
state . audioKeys . splice ( index , 0 , audioKey ) ;
@@ -722,7 +720,7 @@ export const audioStore = createPartialStore<AudioStoreTypes>({
722
720
}
723
721
) {
724
722
const index =
725
- prevAudioKey !== undefined
723
+ prevAudioKey != undefined
726
724
? state . audioKeys . indexOf ( prevAudioKey ) + 1
727
725
: state . audioKeys . length ;
728
726
const audioKeys = audioKeyItemPairs . map ( ( pair ) => pair . audioKey ) ;
@@ -1043,7 +1041,7 @@ export const audioStore = createPartialStore<AudioStoreTypes>({
1043
1041
break ;
1044
1042
case "pause" : {
1045
1043
const pauseMora = query . accentPhrases [ accentPhraseIndex ] . pauseMora ;
1046
- if ( pauseMora !== undefined && pauseMora !== null ) {
1044
+ if ( pauseMora != undefined ) {
1047
1045
pauseMora . vowelLength = data ;
1048
1046
}
1049
1047
break ;
@@ -1169,13 +1167,13 @@ export const audioStore = createPartialStore<AudioStoreTypes>({
1169
1167
audioItem . voice . engineId ,
1170
1168
audioItem . voice . styleId
1171
1169
) ;
1172
- if ( character === undefined )
1173
- throw new Error ( "assert character !== undefined" ) ;
1170
+ if ( character == undefined )
1171
+ throw new Error ( "assert character != undefined" ) ;
1174
1172
1175
1173
const style = character . metas . styles . find (
1176
1174
( style ) => style . styleId === audioItem . voice . styleId
1177
1175
) ;
1178
- if ( style === undefined ) throw new Error ( "assert style != = undefined" ) ;
1176
+ if ( style == undefined ) throw new Error ( "assert style != undefined" ) ;
1179
1177
1180
1178
const styleName = style . styleName || DEFAULT_STYLE_NAME ;
1181
1179
return buildAudioFileNameFromRawData ( fileNamePattern , {
@@ -1199,7 +1197,7 @@ export const audioStore = createPartialStore<AudioStoreTypes>({
1199
1197
const speedScale = query . speedScale ;
1200
1198
1201
1199
let labString = "" ;
1202
- let timestamp = offset !== undefined ? offset : 0 ;
1200
+ let timestamp = offset != undefined ? offset : 0 ;
1203
1201
1204
1202
labString += timestamp . toFixed ( ) + " " ;
1205
1203
timestamp += ( query . prePhonemeLength * 10000000 ) / speedScale ;
@@ -1209,8 +1207,8 @@ export const audioStore = createPartialStore<AudioStoreTypes>({
1209
1207
query . accentPhrases . forEach ( ( accentPhrase ) => {
1210
1208
accentPhrase . moras . forEach ( ( mora ) => {
1211
1209
if (
1212
- mora . consonantLength !== undefined &&
1213
- mora . consonant !== undefined
1210
+ mora . consonantLength != undefined &&
1211
+ mora . consonant != undefined
1214
1212
) {
1215
1213
labString += timestamp . toFixed ( ) + " " ;
1216
1214
timestamp += ( mora . consonantLength * 10000000 ) / speedScale ;
@@ -1226,10 +1224,7 @@ export const audioStore = createPartialStore<AudioStoreTypes>({
1226
1224
labString += mora . vowel + "\n" ;
1227
1225
}
1228
1226
} ) ;
1229
- if (
1230
- accentPhrase . pauseMora !== undefined &&
1231
- accentPhrase . pauseMora !== null
1232
- ) {
1227
+ if ( accentPhrase . pauseMora != undefined ) {
1233
1228
labString += timestamp . toFixed ( ) + " " ;
1234
1229
timestamp +=
1235
1230
( accentPhrase . pauseMora . vowelLength * 10000000 ) / speedScale ;
@@ -1252,8 +1247,8 @@ export const audioStore = createPartialStore<AudioStoreTypes>({
1252
1247
action ( { state } , { audioKey } : { audioKey : AudioKey } ) {
1253
1248
const query = state . audioItems [ audioKey ] . query ;
1254
1249
const accentPhrases = query ?. accentPhrases ;
1255
- if ( query === undefined || accentPhrases = == undefined )
1256
- throw Error ( "query === undefined or accentPhrases = == undefined" ) ;
1250
+ if ( query == undefined || accentPhrases == undefined )
1251
+ throw Error ( "query == undefined or accentPhrases == undefined" ) ;
1257
1252
1258
1253
const offsets : number [ ] = [ ] ;
1259
1254
let length = 0 ;
@@ -1263,7 +1258,7 @@ export const audioStore = createPartialStore<AudioStoreTypes>({
1263
1258
let i = 0 ;
1264
1259
for ( const phrase of accentPhrases ) {
1265
1260
phrase . moras . forEach ( ( m ) => {
1266
- length += m . consonantLength !== undefined ? m . consonantLength : 0 ;
1261
+ length += m . consonantLength != undefined ? m . consonantLength : 0 ;
1267
1262
length += m . vowelLength ;
1268
1263
} ) ;
1269
1264
length += phrase . pauseMora ? phrase . pauseMora . vowelLength : 0 ;
@@ -1347,7 +1342,7 @@ export const audioStore = createPartialStore<AudioStoreTypes>({
1347
1342
{ encodedBlobs } : { encodedBlobs : string [ ] }
1348
1343
) => {
1349
1344
const engineId : EngineId | undefined = state . engineIds [ 0 ] ; // TODO: 複数エンジン対応, 暫定的に音声結合機能は0番目のエンジンのみを使用する
1350
- if ( engineId === undefined )
1345
+ if ( engineId == undefined )
1351
1346
throw new Error ( `No such engine registered: index == 0` ) ;
1352
1347
1353
1348
return dispatch ( "INSTANTIATE_ENGINE_CONNECTOR" , {
@@ -1432,7 +1427,7 @@ export const audioStore = createPartialStore<AudioStoreTypes>({
1432
1427
1433
1428
if ( state . savingSetting . exportLab ) {
1434
1429
const labString = await dispatch ( "GENERATE_LAB" , { audioKey } ) ;
1435
- if ( labString === undefined )
1430
+ if ( labString == undefined )
1436
1431
return {
1437
1432
result : "WRITE_ERROR" ,
1438
1433
path : filePath ,
@@ -1790,7 +1785,7 @@ export const audioStore = createPartialStore<AudioStoreTypes>({
1790
1785
throw new Error ( "accentPhraseOffsets.length === 0" ) ;
1791
1786
const startTime =
1792
1787
accentPhraseOffsets [ getters . AUDIO_PLAY_START_POINT ?? 0 ] ;
1793
- if ( startTime === undefined ) throw Error ( "startTime = == undefined" ) ;
1788
+ if ( startTime == undefined ) throw Error ( "startTime == undefined" ) ;
1794
1789
// 小さい値が切り捨てられることでフォーカスされるアクセントフレーズが一瞬元に戻るので、
1795
1790
// 再生に影響のない程度かつ切り捨てられない値を加算する
1796
1791
offset = startTime + 10e-6 ;
@@ -1809,7 +1804,7 @@ export const audioStore = createPartialStore<AudioStoreTypes>({
1809
1804
presetKey,
1810
1805
} : { audioKey : AudioKey ; presetKey : PresetKey | undefined }
1811
1806
) {
1812
- if ( presetKey === undefined ) {
1807
+ if ( presetKey == undefined ) {
1813
1808
delete state . audioItems [ audioKey ] . presetKey ;
1814
1809
} else {
1815
1810
state . audioItems [ audioKey ] . presetKey = presetKey ;
@@ -1823,7 +1818,7 @@ export const audioStore = createPartialStore<AudioStoreTypes>({
1823
1818
const currentAudioPlayStartPoint = getters . AUDIO_PLAY_START_POINT ;
1824
1819
1825
1820
let index = 0 ;
1826
- if ( currentAudioKey !== undefined ) {
1821
+ if ( currentAudioKey != undefined ) {
1827
1822
index = state . audioKeys . findIndex ( ( v ) => v === currentAudioKey ) ;
1828
1823
}
1829
1824
@@ -1954,7 +1949,7 @@ export const audioCommandStore = transformCommandStore(
1954
1949
const skippedText = extractYomiText ( text ) ;
1955
1950
1956
1951
try {
1957
- if ( query !== undefined ) {
1952
+ if ( query != undefined ) {
1958
1953
const accentPhrases : AccentPhrase [ ] = await dispatch (
1959
1954
"FETCH_ACCENT_PHRASES" ,
1960
1955
{
@@ -2083,7 +2078,7 @@ export const audioCommandStore = transformCommandStore(
2083
2078
audioKeys . map ( async ( audioKey ) => {
2084
2079
try {
2085
2080
const query = state . audioItems [ audioKey ] . query ;
2086
- if ( query !== undefined ) {
2081
+ if ( query != undefined ) {
2087
2082
const accentPhrases = query . accentPhrases ;
2088
2083
const newAccentPhrases : AccentPhrase [ ] = await dispatch (
2089
2084
"FETCH_MORA_DATA" ,
@@ -2148,7 +2143,7 @@ export const audioCommandStore = transformCommandStore(
2148
2143
} : { audioKey : AudioKey ; accentPhraseIndex : number ; accent : number }
2149
2144
) {
2150
2145
const query = state . audioItems [ audioKey ] . query ;
2151
- if ( query !== undefined ) {
2146
+ if ( query != undefined ) {
2152
2147
const newAccentPhrases : AccentPhrase [ ] = JSON . parse (
2153
2148
JSON . stringify ( query . accentPhrases )
2154
2149
) ;
@@ -2206,7 +2201,7 @@ export const audioCommandStore = transformCommandStore(
2206
2201
const engineId = state . audioItems [ audioKey ] . voice . engineId ;
2207
2202
const styleId = state . audioItems [ audioKey ] . voice . styleId ;
2208
2203
2209
- if ( query === undefined ) {
2204
+ if ( query == undefined ) {
2210
2205
throw Error (
2211
2206
"`COMMAND_CHANGE_ACCENT_PHRASE_SPLIT` should not be called if the query does not exist."
2212
2207
) ;
@@ -2405,7 +2400,7 @@ export const audioCommandStore = transformCommandStore(
2405
2400
if ( popUntilPause ) {
2406
2401
while (
2407
2402
newAccentPhrasesSegment [ newAccentPhrasesSegment . length - 1 ]
2408
- . pauseMora === undefined
2403
+ . pauseMora == undefined
2409
2404
) {
2410
2405
newAccentPhrasesSegment . pop ( ) ;
2411
2406
}
@@ -2451,24 +2446,26 @@ export const audioCommandStore = transformCommandStore(
2451
2446
} ,
2452
2447
} ,
2453
2448
2454
- COMMAND_RESET_MORA_PITCH_AND_LENGTH : {
2455
- async action ( { state, dispatch, commit } , { audioKey } ) {
2456
- const engineId = state . audioItems [ audioKey ] . voice . engineId ;
2457
- const styleId = state . audioItems [ audioKey ] . voice . styleId ;
2449
+ COMMAND_MULTI_RESET_MORA_PITCH_AND_LENGTH : {
2450
+ async action ( { state, dispatch, commit } , { audioKeys } ) {
2451
+ for ( const audioKey of audioKeys ) {
2452
+ const engineId = state . audioItems [ audioKey ] . voice . engineId ;
2453
+ const styleId = state . audioItems [ audioKey ] . voice . styleId ;
2458
2454
2459
- const query = state . audioItems [ audioKey ] . query ;
2460
- if ( query === undefined ) throw new Error ( "assert query != = undefined" ) ;
2455
+ const query = state . audioItems [ audioKey ] . query ;
2456
+ if ( query == undefined ) throw new Error ( "assert query != undefined" ) ;
2461
2457
2462
- const newAccentPhrases = await dispatch ( "FETCH_MORA_DATA" , {
2463
- accentPhrases : query . accentPhrases ,
2464
- engineId,
2465
- styleId,
2466
- } ) ;
2458
+ const newAccentPhrases = await dispatch ( "FETCH_MORA_DATA" , {
2459
+ accentPhrases : query . accentPhrases ,
2460
+ engineId,
2461
+ styleId,
2462
+ } ) ;
2467
2463
2468
- commit ( "COMMAND_CHANGE_ACCENT" , {
2469
- audioKey,
2470
- accentPhrases : newAccentPhrases ,
2471
- } ) ;
2464
+ commit ( "COMMAND_CHANGE_ACCENT" , {
2465
+ audioKey,
2466
+ accentPhrases : newAccentPhrases ,
2467
+ } ) ;
2468
+ }
2472
2469
} ,
2473
2470
} ,
2474
2471
@@ -2541,8 +2538,8 @@ export const audioCommandStore = transformCommandStore(
2541
2538
const minMoraLength = 0 ;
2542
2539
const { audioKey, accentPhraseIndex, moraIndex, data, type } = payload ;
2543
2540
const audioItem = draft . audioItems [ audioKey ] ;
2544
- if ( audioItem . query === undefined ) {
2545
- throw Error ( "draft.audioItems[audioKey].query === undefined" ) ;
2541
+ if ( audioItem . query == undefined ) {
2542
+ throw Error ( "draft.audioItems[audioKey].query == undefined" ) ;
2546
2543
}
2547
2544
const accentPhrase = audioItem . query . accentPhrases [ accentPhraseIndex ] ;
2548
2545
const targetMora = accentPhrase . moras [ moraIndex ] ;
@@ -2553,7 +2550,7 @@ export const audioCommandStore = transformCommandStore(
2553
2550
diffData -= targetMora . pitch ;
2554
2551
break ;
2555
2552
case "consonant" :
2556
- if ( targetMora . consonantLength !== undefined ) {
2553
+ if ( targetMora . consonantLength != undefined ) {
2557
2554
diffData -= targetMora . consonantLength ;
2558
2555
}
2559
2556
break ;
@@ -2581,7 +2578,7 @@ export const audioCommandStore = transformCommandStore(
2581
2578
break ;
2582
2579
case "consonant" :
2583
2580
case "vowel" :
2584
- if ( mora . consonantLength !== undefined ) {
2581
+ if ( mora . consonantLength != undefined ) {
2585
2582
audioStore . mutations . SET_AUDIO_MORA_DATA ( draft , {
2586
2583
audioKey,
2587
2584
accentPhraseIndex,
@@ -2843,7 +2840,7 @@ export const audioCommandStore = transformCommandStore(
2843
2840
}
2844
2841
const audioItems : AudioItem [ ] = [ ] ;
2845
2842
let baseAudioItem : AudioItem | undefined = undefined ;
2846
- if ( state . _activeAudioKey !== undefined ) {
2843
+ if ( state . _activeAudioKey != undefined ) {
2847
2844
baseAudioItem = state . audioItems [ state . _activeAudioKey ] ;
2848
2845
}
2849
2846
0 commit comments