File tree Expand file tree Collapse file tree 5 files changed +63
-0
lines changed Expand file tree Collapse file tree 5 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 1
1
import { RestAPI } from "./rest" ;
2
2
import { audioQuery } from "./audio_query" ;
3
3
import { Preset } from "./preset" ;
4
+ import { Speaker } from "./speaker" ;
4
5
5
6
// voicevox client
6
7
/**
@@ -103,4 +104,13 @@ export class Client {
103
104
async deletePreset ( id : number ) : Promise < void > {
104
105
return await this . rest . deletePreset ( id ) ;
105
106
}
107
+
108
+ // Fetch speakers
109
+ /**
110
+ * @returns Speakers
111
+ */
112
+ async fetchSpeakers ( ) : Promise < Speaker [ ] > {
113
+ let speakers = await this . rest . getSpeakers ( ) ;
114
+ return speakers . map ( ( x ) => new Speaker ( x ) ) ;
115
+ }
106
116
}
Original file line number Diff line number Diff line change 4
4
createAudioQueryFromPresetOptions ,
5
5
} from "./types/audioquery" ;
6
6
import { Preset , DeletePresetOptions } from "./types/preset" ;
7
+ import { Speaker } from "./types/speaker" ;
7
8
import { synthesisParams } from "./types/synthesis" ;
8
9
9
10
type fetchOptions = {
@@ -118,4 +119,8 @@ export class RestAPI {
118
119
params : params ,
119
120
} ) ;
120
121
}
122
+
123
+ async getSpeakers ( ) : Promise < Speaker [ ] > {
124
+ return await this . request ( "GET" , "/speakers" ) ;
125
+ }
121
126
}
Original file line number Diff line number Diff line change
1
+ import { Speaker as SpeakerT , Styles , SupportedFeatures } from "./types/speaker" ;
2
+
3
+ // speaker
4
+ export class Speaker {
5
+ public name : string ;
6
+ public speaker_uuid : string ;
7
+ public styles : Styles [ ] ;
8
+ public version : string ;
9
+ public supported_features : SupportedFeatures ;
10
+
11
+ constructor ( speaker : SpeakerT ) {
12
+ this . name = speaker . name ;
13
+ this . speaker_uuid = speaker . speaker_uuid ;
14
+ this . styles = speaker . styles ;
15
+ this . version = speaker . version ;
16
+ this . supported_features = speaker . supported_features ;
17
+ }
18
+ }
Original file line number Diff line number Diff line change
1
+ export type StyleType = "talk" | "singing_teacher" | "frame_decode" | "sing" ;
2
+
3
+ export interface Styles {
4
+ id : number ;
5
+ name : string ;
6
+ type : string ;
7
+ }
8
+
9
+ export interface SupportedFeatures {
10
+ permitted_synthesis_morphing : "ALL" | "SELF_ONLY" | "NOTHING"
11
+ }
12
+
13
+ export interface Speaker {
14
+ name : string ;
15
+ speaker_uuid : string ;
16
+ styles : Styles [ ] ;
17
+ version : string ;
18
+ supported_features : SupportedFeatures ;
19
+ }
Original file line number Diff line number Diff line change
1
+ import assert from "assert" ;
2
+ import Client from "../dist" ;
3
+
4
+ const client = new Client ( "http://127.0.0.1:50021" ) ;
5
+
6
+ async function main ( ) {
7
+ const speakers = await client . fetchSpeakers ( ) ;
8
+ assert ( speakers . length > 0 ) ;
9
+ }
10
+
11
+ main ( ) ;
You can’t perform that action at this time.
0 commit comments