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 11import { RestAPI } from "./rest" ;
22import { audioQuery } from "./audio_query" ;
33import { Preset } from "./preset" ;
4+ import { Speaker } from "./speaker" ;
45
56// voicevox client
67/**
@@ -103,4 +104,13 @@ export class Client {
103104 async deletePreset ( id : number ) : Promise < void > {
104105 return await this . rest . deletePreset ( id ) ;
105106 }
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+ }
106116}
Original file line number Diff line number Diff line change 44 createAudioQueryFromPresetOptions ,
55} from "./types/audioquery" ;
66import { Preset , DeletePresetOptions } from "./types/preset" ;
7+ import { Speaker } from "./types/speaker" ;
78import { synthesisParams } from "./types/synthesis" ;
89
910type fetchOptions = {
@@ -118,4 +119,8 @@ export class RestAPI {
118119 params : params ,
119120 } ) ;
120121 }
122+
123+ async getSpeakers ( ) : Promise < Speaker [ ] > {
124+ return await this . request ( "GET" , "/speakers" ) ;
125+ }
121126}
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