-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.ts
92 lines (83 loc) · 2.55 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import { BasePhrase, phrasesToString } from './phrases.js';
export enum VoiceName {
ChineseWuSimplifiedXiaotong = 'wuu-CN-XiaotongNeural',
ChineseWuSimplifiedYunzhe = 'wuu-CN-YunzheNeural',
ChineseCantoneseSimplified = 'yue-CN-XiaoMinNeural',
ChineseCantoneseTraditional = 'zh-HK-HiuMaanNeural',
ChineseMandarinSimplified = 'zh-CN-XiaoqiuNeural',
EnglishUnitedStates = 'en-US-RyanMultilingualNeural',
EnglishUnitedKingdom = 'en-GB-RyanNeural',
}
export enum StyleType {
ShanghaiMetro = 'shmetro',
}
export enum Stage {
Arrival = 'arr',
Stop = 'stp',
Departure = 'dep',
Midway = 'mdw',
}
export type Variants = Record<string, any>;
export interface Sentence {
mode: 'manual' | 'auto';
/**
* This value should be auto maintained in auto mode.
* User may only change this when mode is manual.
*/
text: string;
variants: Variants;
// phrases: BasePhrase[];
}
/**
* Style should contain the minimal information to generate the phrases.
*/
export interface Project {
style: StyleType;
baseVariants: { [k in Stage]?: { [k in VoiceName]?: Variants } };
stations: { [k: string]: { [k in Stage]?: { [k in VoiceName]?: Sentence } } };
}
/**
* ReconciledPhrases contains only phrases to be resolved to final wav audio files.
*/
export interface ReconciledPhrases {
[k: string]: { [k in Stage]?: { [k in VoiceName]?: BasePhrase[] } };
}
export const reconciledPhrasesToString = (r: ReconciledPhrases) => {
const res: string[] = [];
for (const stn in r) {
for (const stage in r[stn]) {
for (const voiceName in r[stn][stage as Stage]) {
res.push(
// @ts-expect-error This is must have value.
`${stn}_${stage}_${voiceName}: ${phrasesToString(r[stn][stage as Stage][voiceName as VoiceName]!)}`
);
}
}
}
return res;
};
/**
* Contains the possible variants in each stage of each style.
*/
export interface StyleVariants {
[StyleType.ShanghaiMetro]: {
[Stage.Arrival]: {
terminal?: string;
name: string;
doorDirection: 'left' | 'right';
thanksForTaking?: string;
};
[Stage.Departure]: {
welcomeAbroad?: string;
lineName?: string;
terminal?: string;
next: string;
nextDoorDirection: string;
int?: string[][];
noteLastTrain?: boolean;
};
[Stage.Midway]: {
leaveLoveSeat?: boolean;
};
};
}