File tree Expand file tree Collapse file tree 4 files changed +55
-3
lines changed Expand file tree Collapse file tree 4 files changed +55
-3
lines changed Original file line number Diff line number Diff line change 11import { RestAPI } from "./rest" ;
22import { audioQuery } from "./audio_query" ;
3+ import { preset } from "./preset" ;
34
45// voicevox client
56/**
@@ -67,4 +68,10 @@ export class Client {
6768 ) ;
6869 return new audioQuery ( this . rest , audioquery ) ;
6970 }
71+
72+ // Fetch presets
73+ async fetchPresets ( ) : Promise < preset [ ] > {
74+ let presets = await this . rest . getPresets ( ) ;
75+ return presets . map ( ( x ) => new preset ( x ) ) ;
76+ }
7077}
Original file line number Diff line number Diff line change 1+ import { preset as presetT } from "./types/preset" ;
2+
3+ // preset
4+ export class preset {
5+ public id : number ;
6+ public name : string ;
7+ public speaker_uuid : string ;
8+ public style_id : number ;
9+ public speedScale : number ;
10+ public pitchScale : number ;
11+ public intonationScale : number ;
12+ public volumeScale : number ;
13+ public prePhonemeLength : number ;
14+ public postPhonemeLength : number ;
15+
16+ constructor ( preset : presetT ) {
17+ this . id = preset . id ;
18+ this . name = preset . name ;
19+ this . speaker_uuid = preset . speaker_uuid ;
20+ this . style_id = preset . style_id ;
21+ this . speedScale = preset . speedScale ;
22+ this . pitchScale = preset . pitchScale ;
23+ this . intonationScale = preset . intonationScale ;
24+ this . volumeScale = preset . volumeScale ;
25+ this . prePhonemeLength = preset . prePhonemeLength ;
26+ this . postPhonemeLength = preset . postPhonemeLength ;
27+ }
28+ }
Original file line number Diff line number Diff line change 33 createAudioQueryOptions ,
44 createAudioQueryFromPresetOptions ,
55} from "./types/audioquery" ;
6+ import { preset } from "./types/preset" ;
67import { synthesisParams } from "./types/synthesis" ;
78
89type fetchOptions = {
@@ -21,19 +22,19 @@ export class RestAPI {
2122 async request (
2223 method : string ,
2324 path : string ,
24- options : {
25+ options ? : {
2526 body ?: any ;
2627 params ?: any ;
2728 }
2829 ) : Promise < any > {
2930 let url = this . engine_url + path ;
30- if ( options . params ) {
31+ if ( options ? .params ) {
3132 url += "?" + new URLSearchParams ( options . params ) . toString ( ) ;
3233 }
3334 var fetch_options : fetchOptions = {
3435 method : method ,
3536 } ;
36- if ( options . body ) {
37+ if ( options ? .body ) {
3738 fetch_options [ "headers" ] = { "Content-Type" : "application/json" } ;
3839 fetch_options [ "body" ] = JSON . stringify ( options . body ) ;
3940 }
@@ -92,4 +93,8 @@ export class RestAPI {
9293 params : params ,
9394 } ) ;
9495 }
96+
97+ async getPresets ( ) : Promise < preset [ ] > {
98+ return await this . request ( "GET" , "/presets" ) ;
99+ }
95100}
Original file line number Diff line number Diff line change 1+ export interface preset {
2+ id : number ;
3+ name : string ;
4+ speaker_uuid : string ;
5+ style_id : number ;
6+ speedScale : number ;
7+ pitchScale : number ;
8+ intonationScale : number ;
9+ volumeScale : number ;
10+ prePhonemeLength : number ;
11+ postPhonemeLength : number ;
12+ }
You can’t perform that action at this time.
0 commit comments