From b6899b99f29f8b958384d5c60660108dd0d333ea Mon Sep 17 00:00:00 2001 From: Kodai Aoyama Date: Mon, 17 Jul 2023 18:46:35 +0900 Subject: [PATCH] add default parameter support --- README.md | 25 ++++++++++++------------- src/speech.nim | 14 +++++++------- voicepeaky.nimble | 2 +- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 446f7b5..d0be340 100644 --- a/README.md +++ b/README.md @@ -35,18 +35,17 @@ curl -X POST -H "Content-Type: application/json" -d '@sample.json' localhost:999 RequestBody (JSON Format) is below. see a sample [here](https://raw.githubusercontent.com/solaoi/voicepeaky/main/sample.json). -| Field | Type | Sample | -| ------------- | ----------------------- | --------------------- | -| - (parent) | JSONObject | - | -| narrator | string*1 | "Japanese Male Child" | -| emotion | JSONObject | - | -| emotion/happy | number(0 - 100) | 0 | -| emotion/fun | number(0 - 100) | 0 | -| emotion/angry | number(0 - 100) | 0 | -| emotion/sad | number(0 - 100) | 0 | -| speed | number(50 - 200) | 100 | -| pitch | number(-300 - 300) | 0 | -| text | string | "こんにちは" | +| Field | Type | Default | Required | +| ------------- | ----------------------- | ------------------- | -------- | +| narrator | string*1 | "Japanese Female 1" | false | +| emotion | JSONObject | - | false | +| emotion/happy | number(0 - 100) | 0 | false | +| emotion/fun | number(0 - 100) | 0 | false | +| emotion/angry | number(0 - 100) | 0 | false | +| emotion/sad | number(0 - 100) | 0 | false | +| speed | number(50 - 200) | 100 | false | +| pitch | number(-300 - 300) | 0 | false | +| text | string | - | true | *1 | Types of Narrators | Requirements | @@ -78,7 +77,7 @@ brew upgrade voicepeaky ```sh # Install with wget or curl ## set the latest version on releases. -VERSION=v1.0.3 +VERSION=v1.0.4 ## set the OS you use. (macos) OS=linux ## case you use wget diff --git a/src/speech.nim b/src/speech.nim index 72c3b27..0ccec43 100644 --- a/src/speech.nim +++ b/src/speech.nim @@ -16,13 +16,13 @@ type proc createSpeech*(json:JsonNode, text:string) :Speech= result = new Speech try: - result.narrator = json["narrator"].getStr - result.happy = json["emotion"]["happy"].getInt - result.fun = json["emotion"]["fun"].getInt - result.angry = json["emotion"]["angry"].getInt - result.sad = json["emotion"]["sad"].getInt - result.speed = json["speed"].getInt - result.pitch = json["pitch"].getInt + result.narrator = json{"narrator"}.getStr("Japanese Female 1") + result.happy = json{"emotion"}{"happy"}.getInt(0) + result.fun = json{"emotion"}{"fun"}.getInt(0) + result.angry = json{"emotion"}{"angry"}.getInt(0) + result.sad = json{"emotion"}{"sad"}.getInt(0) + result.speed = json{"speed"}.getInt(100) + result.pitch = json{"pitch"}.getInt(0) result.text = text except: raise newException(SpeechInitError, fmt"request body is invalid") diff --git a/voicepeaky.nimble b/voicepeaky.nimble index 6ce5433..268cd4d 100644 --- a/voicepeaky.nimble +++ b/voicepeaky.nimble @@ -1,6 +1,6 @@ # Package -version = "1.0.3" +version = "1.0.4" author = "solaoi" description = "Voicepeak Server" license = "MIT"