Fangjun Kuang
Committed by GitHub

Fix android tts audio buffer size and fix CI. (#478)

@@ -26,8 +26,8 @@ jobs: @@ -26,8 +26,8 @@ jobs:
26 fail-fast: false 26 fail-fast: false
27 matrix: 27 matrix:
28 os: [ubuntu-latest] 28 os: [ubuntu-latest]
29 - total: ["30"]  
30 - index: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29"] 29 + total: ["40"]
  30 + index: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39"]
31 31
32 steps: 32 steps:
33 - uses: actions/checkout@v4 33 - uses: actions/checkout@v4
@@ -74,7 +74,7 @@ jobs: @@ -74,7 +74,7 @@ jobs:
74 export PATH=/c/hostedtoolcache/windows/Python/3.8.10/x64/bin:$PATH 74 export PATH=/c/hostedtoolcache/windows/Python/3.8.10/x64/bin:$PATH
75 export PATH=/c/hostedtoolcache/windows/Python/3.9.13/x64/bin:$PATH 75 export PATH=/c/hostedtoolcache/windows/Python/3.9.13/x64/bin:$PATH
76 export PATH=/c/hostedtoolcache/windows/Python/3.10.11/x64/bin:$PATH 76 export PATH=/c/hostedtoolcache/windows/Python/3.10.11/x64/bin:$PATH
77 - export PATH=/c/hostedtoolcache/windows/Python/3.11.6/x64/bin:$PATH 77 + export PATH=/c/hostedtoolcache/windows/Python/3.11.7/x64/bin:$PATH
78 78
79 which sherpa-onnx 79 which sherpa-onnx
80 sherpa-onnx --help 80 sherpa-onnx --help
@@ -65,8 +65,6 @@ jobs: @@ -65,8 +65,6 @@ jobs:
65 run: | 65 run: |
66 mkdir tts-waves 66 mkdir tts-waves
67 67
68 - cp -v go-api-examples/non-streaming-tts/*.sh scripts/go/_internal/non-streaming-tts/  
69 -  
70 cd scripts/go/_internal/non-streaming-tts/ 68 cd scripts/go/_internal/non-streaming-tts/
71 ls -lh 69 ls -lh
72 go mod tidy 70 go mod tidy
@@ -106,8 +104,6 @@ jobs: @@ -106,8 +104,6 @@ jobs:
106 - name: Test non-streaming decoding files (macOS) 104 - name: Test non-streaming decoding files (macOS)
107 shell: bash 105 shell: bash
108 run: | 106 run: |
109 - cp -v go-api-examples/non-streaming-decode-files/*.sh scripts/go/_internal/non-streaming-decode-files/  
110 -  
111 cd scripts/go/_internal/non-streaming-decode-files/ 107 cd scripts/go/_internal/non-streaming-decode-files/
112 ls -lh 108 ls -lh
113 go mod tidy 109 go mod tidy
@@ -148,7 +144,6 @@ jobs: @@ -148,7 +144,6 @@ jobs:
148 - name: Test streaming decoding files 144 - name: Test streaming decoding files
149 shell: bash 145 shell: bash
150 run: | 146 run: |
151 - cp -v go-api-examples/streaming-decode-files/*.sh scripts/go/_internal/streaming-decode-files  
152 cd scripts/go/_internal/streaming-decode-files 147 cd scripts/go/_internal/streaming-decode-files
153 ls -lh 148 ls -lh
154 go mod tidy 149 go mod tidy
@@ -66,7 +66,7 @@ jobs: @@ -66,7 +66,7 @@ jobs:
66 export PATH=/c/hostedtoolcache/windows/Python/3.8.10/x64/bin:$PATH 66 export PATH=/c/hostedtoolcache/windows/Python/3.8.10/x64/bin:$PATH
67 export PATH=/c/hostedtoolcache/windows/Python/3.9.13/x64/bin:$PATH 67 export PATH=/c/hostedtoolcache/windows/Python/3.9.13/x64/bin:$PATH
68 export PATH=/c/hostedtoolcache/windows/Python/3.10.11/x64/bin:$PATH 68 export PATH=/c/hostedtoolcache/windows/Python/3.10.11/x64/bin:$PATH
69 - export PATH=/c/hostedtoolcache/windows/Python/3.11.6/x64/bin:$PATH 69 + export PATH=/c/hostedtoolcache/windows/Python/3.11.7/x64/bin:$PATH
70 70
71 71
72 sherpa-onnx --help 72 sherpa-onnx --help
@@ -61,7 +61,11 @@ class MainActivity : AppCompatActivity() { @@ -61,7 +61,11 @@ class MainActivity : AppCompatActivity() {
61 61
62 private fun initAudioTrack() { 62 private fun initAudioTrack() {
63 val sampleRate = tts.sampleRate() 63 val sampleRate = tts.sampleRate()
64 - val bufLength = (sampleRate * 0.1).toInt() 64 + val bufLength = AudioTrack.getMinBufferSize(
  65 + sampleRate,
  66 + AudioFormat.CHANNEL_OUT_MONO,
  67 + AudioFormat.ENCODING_PCM_FLOAT
  68 + )
65 Log.i(TAG, "sampleRate: ${sampleRate}, buffLength: ${bufLength}") 69 Log.i(TAG, "sampleRate: ${sampleRate}, buffLength: ${bufLength}")
66 70
67 val attr = AudioAttributes.Builder().setContentType(AudioAttributes.CONTENT_TYPE_SPEECH) 71 val attr = AudioAttributes.Builder().setContentType(AudioAttributes.CONTENT_TYPE_SPEECH)
@@ -250,11 +250,16 @@ def main(): @@ -250,11 +250,16 @@ def main():
250 250
251 start = index * num_per_runner 251 start = index * num_per_runner
252 end = start + num_per_runner 252 end = start + num_per_runner
253 - if index == args.total - 1:  
254 - end = num_models 253 +
  254 + remaining = num_models - args.total * num_per_runner
255 255
256 print(f"{index}/{total}: {start}-{end}/{num_models}") 256 print(f"{index}/{total}: {start}-{end}/{num_models}")
257 d["tts_model_list"] = all_model_list[start:end] 257 d["tts_model_list"] = all_model_list[start:end]
  258 + if index < remaining:
  259 + s = args.total * num_per_runner + index
  260 + d["tts_model_list"].append(all_model_list[s])
  261 + print(f"{s}/{num_models}")
  262 +
258 s = template.render(**d) 263 s = template.render(**d)
259 with open("./build-apk-tts.sh", "w") as f: 264 with open("./build-apk-tts.sh", "w") as f:
260 print(s, file=f) 265 print(s, file=f)
  1 +../../../../go-api-examples/non-streaming-tts/run-vits-ljs.sh
  1 +../../../../go-api-examples/non-streaming-tts/run-vits-piper-en_US-lessac-medium.sh
  1 +../../../../go-api-examples/non-streaming-tts/run-vits-vctk.sh
  1 +../../../../go-api-examples/non-streaming-tts/run-vits-zh-aishell3.sh