Skip to content

Commit 0827aaa

Browse files
authored
Multilingual demos (#85)
1 parent c110b3d commit 0827aaa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2487
-189
lines changed

.github/workflows/dotnet-demos.yml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,21 @@ jobs:
4545
run: dotnet build -c StreamingDemo.Release
4646

4747
- name: Run .NET file demo
48-
run: dotnet run -c FileDemo.Release -- --access_key ${{secrets.PV_VALID_ACCESS_KEY}} --text "Hello, I am Orca!" --output_path ./tmp.wav
48+
run: >
49+
dotnet run -c FileDemo.Release --
50+
--access_key ${{secrets.PV_VALID_ACCESS_KEY}}
51+
--language en
52+
--gender female
53+
--text "Hello, I am Orca!"
54+
--output_path ./tmp.wav
4955
5056
- name: Run .NET streaming demo
51-
run: dotnet run -c StreamingDemo.Release -- --access_key ${{secrets.PV_VALID_ACCESS_KEY}} --text_to_stream "Hello, I am Orca!"
57+
run: >
58+
dotnet run -c StreamingDemo.Release --
59+
--access_key ${{secrets.PV_VALID_ACCESS_KEY}}
60+
--language en
61+
--gender female
62+
--text_to_stream "Hello, I am Orca!"
5263
5364
build-self-hosted:
5465
runs-on: ${{ matrix.machine }}
@@ -70,7 +81,18 @@ jobs:
7081
run: dotnet build -c StreamingDemo.Release
7182

7283
- name: Run .NET file demo
73-
run: dotnet run -c FileDemo.Release -- --access_key ${{secrets.PV_VALID_ACCESS_KEY}} --text "Hello, I am Orca!" --output_path ./tmp.wav
84+
run: >
85+
dotnet run -c FileDemo.Release --
86+
--access_key ${{secrets.PV_VALID_ACCESS_KEY}}
87+
--language en
88+
--gender female
89+
--text "Hello, I am Orca!"
90+
--output_path ./tmp.wav
7491
7592
- name: Run .NET streaming demo
76-
run: dotnet run -c StreamingDemo.Release -- --access_key ${{secrets.PV_VALID_ACCESS_KEY}} --text_to_stream "Hello, I am Orca!"
93+
run: >
94+
dotnet run -c StreamingDemo.Release --
95+
--access_key ${{secrets.PV_VALID_ACCESS_KEY}}
96+
--language en
97+
--gender female
98+
--text_to_stream "Hello, I am Orca!"

.github/workflows/ios-demos.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,20 @@ jobs:
2626
- name: Checkout
2727
uses: actions/checkout@v3
2828

29-
- name: Build Demo
29+
- name: Build English
3030
run: xcrun xcodebuild build
3131
-configuration Debug
3232
-project OrcaDemo.xcodeproj
3333
-sdk iphoneos
34-
-scheme OrcaDemo
34+
-scheme enFemaleDemo
3535
-derivedDataPath ddp
3636
CODE_SIGNING_ALLOWED=NO
37+
38+
- name: Build Other Language
39+
run: xcrun xcodebuild build
40+
-configuration Debug
41+
-project OrcaDemo.xcodeproj
42+
-sdk iphoneos
43+
-scheme frMaleDemo
44+
-derivedDataPath ddp
45+
CODE_SIGNING_ALLOWED=NO

.github/workflows/nodejs-demos.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ jobs:
4949
yarn install
5050
5151
- name: Test streaming
52-
run: yarn streaming -a ${{secrets.PV_VALID_ACCESS_KEY}} -t "Hello, I am Orca!"
52+
run: yarn streaming -a ${{secrets.PV_VALID_ACCESS_KEY}} -m ../../lib/common/orca_params_en_female.pv -t "Hello, I am Orca!"
5353

5454
- name: Test file
55-
run: yarn file -a ${{secrets.PV_VALID_ACCESS_KEY}} -t "Hello, I am Orca!" -o "./tmp.wav"
55+
run: yarn file -a ${{secrets.PV_VALID_ACCESS_KEY}} -m ../../lib/common/orca_params_en_female.pv -t "Hello, I am Orca!" -o "./tmp.wav"
5656

5757
build-self-hosted:
5858
runs-on: ${{ matrix.machine }}
@@ -68,7 +68,7 @@ jobs:
6868
run: yarn install
6969

7070
- name: Test streaming
71-
run: yarn streaming -a ${{secrets.PV_VALID_ACCESS_KEY}} -t "Hello, I am Orca!"
71+
run: yarn streaming -a ${{secrets.PV_VALID_ACCESS_KEY}} -m ../../lib/common/orca_params_en_female.pv -t "Hello, I am Orca!"
7272

7373
- name: Test file
74-
run: yarn file -a ${{secrets.PV_VALID_ACCESS_KEY}} -t "Hello, I am Orca!" -o "./tmp.wav"
74+
run: yarn file -a ${{secrets.PV_VALID_ACCESS_KEY}} -m ../../lib/common/orca_params_en_female.pv -t "Hello, I am Orca!" -o "./tmp.wav"

.github/workflows/python-demo.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,15 @@ jobs:
5454
python3 orca_demo_streaming.py
5555
--access_key ${{secrets.PV_VALID_ACCESS_KEY}}
5656
--text_to_stream "Hello, I am Orca!"
57+
--model_path ../../lib/common/orca_params_en_female.pv
5758
5859
- name: Test single
5960
run: >
6061
python3 orca_demo.py
6162
--access_key ${{secrets.PV_VALID_ACCESS_KEY}}
6263
--text "Hello, I am Orca!"
6364
--output_path ./tmp.wav
65+
--model_path ../../lib/common/orca_params_en_female.pv
6466
6567
build-self-hosted:
6668
runs-on: ${{ matrix.machine }}
@@ -80,10 +82,12 @@ jobs:
8082
python3 orca_demo_streaming.py
8183
--access_key ${{secrets.PV_VALID_ACCESS_KEY}}
8284
--text_to_stream "Hello, I am Orca!"
85+
--model_path ../../lib/common/orca_params_en_female.pv
8386
8487
- name: Test single
8588
run: >
8689
python3 orca_demo.py
8790
--access_key ${{secrets.PV_VALID_ACCESS_KEY}}
8891
--text "Hello, I am Orca!"
8992
--output_path ./tmp.wav
93+
--model_path ../../lib/common/orca_params_en_female.pv

README.md

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,16 @@ pip3 install pvorcademo
145145
Run the streaming demo:
146146

147147
```console
148-
orca_demo_streaming --access_key ${ACCESS_KEY} --text_to_stream ${TEXT}
148+
orca_demo_streaming --access_key ${ACCESS_KEY} --model_path ${MODEL_PATH} --text_to_stream ${TEXT}
149149
```
150150

151151
Run the single synthesis demo:
152152

153153
```console
154-
orca_demo --access_key ${ACCESS_KEY} --text ${TEXT} --output_path ${WAV_OUTPUT_PATH}
154+
orca_demo --access_key ${ACCESS_KEY} --model_path ${MODEL_PATH} --text ${TEXT} --output_path ${WAV_OUTPUT_PATH}
155155
```
156156

157-
Replace `${ACCESS_KEY}` with yours obtained from Picovoice Console, `${TEXT}` with the text to be synthesized, and
157+
Replace `${ACCESS_KEY}` with yours obtained from Picovoice Console, `${MODEL_PATH}` with a path to any of the model files available under [lib/common](lib/common), `${TEXT}` with the text to be synthesized, and
158158
`${WAV_OUTPUT_PATH}` with a path to an output WAV file.
159159

160160
For more information about Python demos go to [demo/python](demo/python).
@@ -170,13 +170,13 @@ dotnet build -c StreamingDemo.Release
170170
Run the streaming demo:
171171

172172
```console
173-
dotnet build -c StreamingDemo.Release -- --access_key ${ACCESS_KEY} --text_to_stream ${TEXT}
173+
dotnet build -c StreamingDemo.Release -- --access_key ${ACCESS_KEY} --language ${LANGUAGE} --gender ${GENDER} --text_to_stream ${TEXT}
174174
```
175175

176176
Run the single synthesis demo:
177177

178178
```console
179-
dotnet build -c FileDemo.Release -- --access_key ${ACCESS_KEY} --text ${TEXT} --output_path ${WAV_OUTPUT_PATH}
179+
dotnet build -c FileDemo.Release -- --access_key ${ACCESS_KEY} --language ${LANGUAGE} --gender ${GENDER} --text ${TEXT} --output_path ${WAV_OUTPUT_PATH}
180180
```
181181

182182
Replace `${ACCESS_KEY}` with yours obtained from Picovoice Console, `${TEXT}` with the text to be synthesized, and
@@ -186,16 +186,11 @@ For more information about .NET demos go to [demo/dotnet](demo/dotnet).
186186

187187
### iOS Demo
188188

189-
Run the following from [demo/ios](demo/ios) to install the Orca-iOS CocoaPod:
190-
191-
```console
192-
pod install
193-
```
194-
195-
Replace `let ACCESS_KEY = "..."` inside [ViewModel.swift](demo/ios/OrcaDemo/OrcaDemo/ViewModel.swift) with yours
196-
obtained from [Picovoice Console](https://console.picovoice.ai/).
197-
198-
Then, using Xcode, open the generated OrcaDemo.xcworkspace and run the application.
189+
1. Open [OrcaDemo.xcodeproj](demo/ios/OrcaDemo/OrcaDemo.xcodeproj) in XCode.
190+
2. Replace `${YOUR_ACCESS_KEY_HERE}` in the file [`ViewModel.swift`](demo/ios/OrcaDemo/OrcaDemo/ViewModel.swift) with your `AccessKey`.
191+
3. Go to `Product > Scheme` and select the scheme for the language and gender you would like to run the demo in (e.g. `enFemaleDemo` -> English Demo with a female voice, `deMaleDemo` -> German demo with a male voice).
192+
4. Run the demo with a simulator or connected iOS device.
193+
5. Once the demo app has started, enter the text you wish to synthesize in the text box area, and press the `Synthesize` button to synthesize the text and play audio.
199194

200195
For more information about iOS demos go to [demo/ios](demo/ios).
201196

@@ -213,33 +208,45 @@ Run the demo:
213208
./demo/c/build/orca_demo_streaming -l ${LIBRARY_PATH} -m ${MODEL_PATH} -a ${ACCESS_KEY} -t ${TEXT} -o ${OUTPUT_PATH}
214209
```
215210

211+
For more information about C demos go to [demo/c](demo/c).
212+
216213
### Web Demos
217214

218215
From [demo/web](./demo/web) run the following in the terminal:
219216

220217
```console
221218
yarn
222-
yarn start
219+
yarn start ${LANGUAGE} ${GENDER}
223220
```
224221

225222
(or)
226223

227224
```console
228225
npm install
229-
npm run start
226+
npm run start ${LANGUAGE} ${GENDER}
230227
```
231228

229+
Replace `${LANGUAGE}` and `${GENDER}` with the language and gender you would like to run the demo in.
230+
Available languages are `en`, `es`, `de`, `fr`, `ko`, `ja`, `it`, `pt`, and available genders are `male` and `female`.
231+
232232
Open `http://localhost:5000` in your browser to try the demo.
233233

234+
For more information about Web demos go to [demo/web](demo/web).
235+
234236
### Android Demo
235237

236-
Using Android Studio, open [demo/android/OrcaDemo](./demo/android/OrcaDemo) as an Android project and then run the
237-
application.
238+
Using Android Studio, open [demo/android/OrcaDemo](./demo/android/OrcaDemo) as an Android project.
238239

239240
Replace `"${YOUR_ACCESS_KEY_HERE}"` in the
240241
file [MainActivity.java](./demo/android/OrcaDemo/orca-demo-app/src/main/java/ai/picovoice/orcademo/MainActivity.java)
241242
with your `AccessKey`.
242243

244+
Go to `Build > Select Build Variant...` and select the language and gender you would like to run the demo in (e.g. `enFemaleDebug` -> English Demo with a female voice, `deMaleRelease` -> German Demo with a male voice).
245+
246+
Build and run on an installed simulator or a connected Android device.
247+
248+
For more information about Android demos go to [demo/android](demo/android).
249+
243250
### Node.js Demos
244251

245252
Install the demo package:
@@ -251,19 +258,18 @@ yarn global add @picovoice/orca-node-demo
251258
Run the streaming demo:
252259

253260
```console
254-
orca-streaming-demo --access_key ${ACCESS_KEY} --text_to_stream ${TEXT}
261+
orca-streaming-demo --access_key ${ACCESS_KEY} --model_file_path ${MODEL_FILE_PATH} --text_to_stream ${TEXT}
255262
```
256263

257264
Run the file demo:
258265

259266
```console
260-
orca-file-demo --access_key ${ACCESS_KEY} --text ${TEXT} --output_path ${AUDIO_PATH}
267+
orca-file-demo --access_key ${ACCESS_KEY} --model_file_path ${MODEL_FILE_PATH} --text ${TEXT} --output_path ${AUDIO_PATH}
261268
```
262269

263-
Replace `${ACCESS_KEY}` with yours obtained from Picovoice Console, `${TEXT}` with the text to be synthesized, and
264-
`${AUDIO_PATH}` with a path to an output WAV file.
270+
Replace `${ACCESS_KEY}` with yours obtained from Picovoice Console, `${MODEL_FILE_PATH}` with a path to any of the model files available under [lib/common](lib/common), `${TEXT}` with your text to be synthesized, and `${WAV_OUTPUT_PATH}` with a path to a `.wav` file where the generated audio will be stored as a single-channel, 16-bit PCM `.wav` file.
265271

266-
For more information about Node.js demos go to [demo/nodejs](./demo/nodejs).
272+
For more information about Node.js demos go to [demo/nodejs](demo/nodejs).
267273

268274
## SDKs
269275

demo/android/OrcaDemo/README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,13 @@ Signup or Login to [Picovoice Console](https://console.picovoice.ai/) to get you
99

1010
## Setup
1111

12-
Replace `"${YOUR_ACCESS_KEY_HERE}"`
13-
inside [MainActivity.java](orca-demo-app/src/main/java/ai/picovoice/orcademo/MainActivity.java)
14-
with your AccessKey obtained from [Picovoice Console](https://console.picovoice.ai/).
15-
1612
1. Open the project in Android Studio
17-
2. Build and run on an installed simulator or a connected Android device
13+
2. Replace `${YOUR_ACCESS_KEY_HERE}` in the file [MainActivity.java](./orca-demo-app/src/main/java/ai/picovoice/orcademo/MainActivity.java) with your `AccessKey`.
14+
3. Go to `Build > Select Build Variant...` and select the language and gender you would like to run the demo in (e.g. `enFemaleDebug` -> English Demo with a female voice, `deMaleRelease` -> German Demo with a male voice)
15+
4. Build and run on an installed simulator or a connected Android device
1816

1917
## Usage
2018

2119
1. Choose between Streaming Synthesis and Single Synthesis using the switch at the top.
2220
2. Type a phrase that you'd like to synthesize into the textbox.
23-
3. Press the `Synthesize` button to hear the synthesized speech.
24-
21+
3. Press the `Synthesize` button to hear the synthesized speech.

demo/android/OrcaDemo/orca-demo-app/build.gradle

Lines changed: 77 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import groovy.json.JsonSlurper
2+
13
apply plugin: 'com.android.application'
24

35
android {
@@ -20,6 +22,51 @@ android {
2022
}
2123
}
2224

25+
def testDataFile = file('../../../../resources/.test/test_data.json')
26+
def parsedJson = new JsonSlurper().parseText(testDataFile.text)
27+
def models = []
28+
parsedJson.tests.sentence_tests.each { test ->
29+
test.models.each { m ->
30+
def (language, gender) = m.replace("orca_params_", "").replace(".pv", "").split("_")
31+
def flavor = "${language}${gender.capitalize()}"
32+
models.add(flavor)
33+
}
34+
}
35+
36+
flavorDimensions "model"
37+
productFlavors {
38+
if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
39+
enFemale {
40+
getIsDefault().set(true)
41+
}
42+
}
43+
44+
models.each { model ->
45+
"$model" {
46+
applicationIdSuffix ".$model"
47+
}
48+
}
49+
50+
all { flavor ->
51+
delete fileTree("$projectDir/src/main/assets") {
52+
exclude '**/.gitkeep'
53+
}
54+
55+
def language = flavor.name.substring(0, 2)
56+
def gender = flavor.name.substring(2)
57+
def modelName = "orca_params_" + language + "_" + gender.toLowerCase() + ".pv"
58+
def modelFile = file("$projectDir/../../../../lib/common/$modelName")
59+
60+
if (modelFile.exists()) {
61+
task("${flavor.name}CopyParams", type: Copy) {
62+
from(modelFile.parent)
63+
include(modelName)
64+
into("$projectDir/src/${flavor.name}/assets/models")
65+
}
66+
}
67+
}
68+
}
69+
2370
buildFeatures {
2471
buildConfig true
2572
}
@@ -42,10 +89,34 @@ dependencies {
4289
implementation 'ai.picovoice:orca-android:1.1.1'
4390
}
4491

45-
tasks.register('copyParams', Copy) {
46-
from("${rootDir}/../../../lib/common")
47-
include('orca_params_en_female.pv')
48-
into("${rootDir}/orca-demo-app/src/main/assets")
49-
}
92+
afterEvaluate {
93+
android.productFlavors.all {
94+
flavor ->
95+
tasks."merge${flavor.name.capitalize()}DebugAssets".dependsOn "${flavor.name}CopyParams"
96+
tasks."merge${flavor.name.capitalize()}ReleaseAssets".dependsOn "${flavor.name}CopyParams"
5097

51-
preBuild.dependsOn(copyParams)
98+
def generateDebugLintReportModelTask = tasks.findByName(
99+
"generate${flavor.name.capitalize()}DebugLintReportModel")
100+
if (generateDebugLintReportModelTask) {
101+
generateDebugLintReportModelTask.dependsOn "${flavor.name}CopyParams"
102+
}
103+
104+
def generateReleaseLintVitalReportModelTask = tasks.findByName(
105+
"generate${flavor.name.capitalize()}ReleaseLintVitalReportModel")
106+
if (generateReleaseLintVitalReportModelTask) {
107+
generateReleaseLintVitalReportModelTask.dependsOn "${flavor.name}CopyParams"
108+
}
109+
110+
def lintAnalyzeDebugTask = tasks.findByName(
111+
"lintAnalyze${flavor.name.capitalize()}Debug")
112+
if (lintAnalyzeDebugTask) {
113+
lintAnalyzeDebugTask.dependsOn "${flavor.name}CopyParams"
114+
}
115+
116+
def lintVitalAnalyzeReleaseTask = tasks.findByName(
117+
"lintVitalAnalyze${flavor.name.capitalize()}Release")
118+
if (lintVitalAnalyzeReleaseTask) {
119+
lintVitalAnalyzeReleaseTask.dependsOn "${flavor.name}CopyParams"
120+
}
121+
}
122+
}

0 commit comments

Comments
 (0)