@ -0,0 +1,7 @@
|
|||||||
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<style name="Base.Theme.Notesmaster" parent="Theme.Material3.DayNight.NoActionBar">
|
||||||
|
<!-- Customize your dark theme here. -->
|
||||||
|
<!-- <item name="colorPrimary">@color/my_dark_primary</item> -->
|
||||||
|
</style>
|
||||||
|
</resources>
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!-- Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<resources>
|
||||||
|
<style name="NoteTheme" parent="@android:style/Theme.Material.Light">
|
||||||
|
<item name="android:actionBarStyle">@android:style/Widget.Material.Light.ActionBar</item>
|
||||||
|
<item name="android:displayOptions">showHome|showTitle|useLogo</item>
|
||||||
|
<item name="android:windowActionBar">true</item>
|
||||||
|
<item name="android:windowNoTitle">false</item>
|
||||||
|
<item name="android:windowSoftInputMode">adjustResize</item>
|
||||||
|
<item name="android:windowContentOverlay">@null</item>
|
||||||
|
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||||
|
<item name="android:windowTranslucentStatus">true</item>
|
||||||
|
<item name="android:windowTranslucentNavigation">true</item>
|
||||||
|
</style>
|
||||||
|
</resources>
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!-- Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<resources>
|
||||||
|
<string-array name="menu_share_ways">
|
||||||
|
<item>短信</item>
|
||||||
|
<item>邮件</item>
|
||||||
|
</string-array>
|
||||||
|
</resources>
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!-- Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<resources>
|
||||||
|
<string-array name="menu_share_ways">
|
||||||
|
<item>短信</item>
|
||||||
|
<item>郵件</item>
|
||||||
|
</string-array>
|
||||||
|
</resources>
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!-- Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<resources>
|
||||||
|
<!-- Backup format -->
|
||||||
|
<string-array name="format_for_exported_note">
|
||||||
|
<item>-%s</item> <!-- format_folder_name -->
|
||||||
|
<item>--%s</item> <!-- format_folder_note_date -->
|
||||||
|
<item>--%s</item> <!-- format_note_date -->
|
||||||
|
<item>--%s</item> <!-- format_note_content -->
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="menu_share_ways">
|
||||||
|
<item>Messaging</item>
|
||||||
|
<item>Email</item>
|
||||||
|
</string-array>
|
||||||
|
</resources>
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!-- Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<resources>
|
||||||
|
<color name="user_query_highlight">#335b5b5b</color>
|
||||||
|
</resources>
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!-- Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<resources>
|
||||||
|
<dimen name="text_font_size_super">33sp</dimen>
|
||||||
|
<dimen name="text_font_size_large">26sp</dimen>
|
||||||
|
<dimen name="text_font_size_medium">20sp</dimen>
|
||||||
|
<dimen name="text_font_size_normal">17sp</dimen>
|
||||||
|
<dimen name="text_font_size_small">14sp</dimen>
|
||||||
|
</resources>
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<!-- 定义退出搜索菜单项的ID -->
|
||||||
|
<item name="menu_exit_search" type="id" />
|
||||||
|
</resources>
|
||||||
@ -0,0 +1,74 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!-- Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<resources>
|
||||||
|
<style name="TextAppearanceSuper">
|
||||||
|
<item name="android:textSize">@dimen/text_font_size_super</item>
|
||||||
|
<item name="android:textColorLink">#0000ff</item>
|
||||||
|
</style>
|
||||||
|
<style name="TextAppearanceLarge">
|
||||||
|
<item name="android:textSize">@dimen/text_font_size_large</item>
|
||||||
|
<item name="android:textColorLink">#0000ff</item>
|
||||||
|
</style>
|
||||||
|
<style name="TextAppearanceMedium">
|
||||||
|
<item name="android:textSize">@dimen/text_font_size_medium</item>
|
||||||
|
<item name="android:textColorLink">#0000ff</item>
|
||||||
|
</style>
|
||||||
|
<style name="TextAppearanceNormal">
|
||||||
|
<item name="android:textSize">@dimen/text_font_size_normal</item>
|
||||||
|
<item name="android:textColorLink">#0000ff</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="TextAppearancePrimaryItem">
|
||||||
|
<item name="android:textSize">@dimen/text_font_size_normal</item>
|
||||||
|
<item name="android:textColor">@color/primary_text_dark</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="TextAppearanceSecondaryItem">
|
||||||
|
<item name="android:textSize">@dimen/text_font_size_small</item>
|
||||||
|
<item name="android:textColor">@color/secondary_text_dark</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="TextAppearanceUnderMenuIcon">
|
||||||
|
<item name="android:textSize">@dimen/text_font_size_normal</item>
|
||||||
|
<item name="android:textColor">@android:color/black</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="HighlightTextAppearancePrimary">
|
||||||
|
<item name="android:textSize">@dimen/text_font_size_normal</item>
|
||||||
|
<item name="android:textColor">@color/primary_text_dark</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="HighlightTextAppearanceSecondary">
|
||||||
|
<item name="android:textSize">@dimen/text_font_size_small</item>
|
||||||
|
<item name="android:textColor">@color/secondary_text_dark</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="NoteTheme" parent="@android:style/Theme.Holo.Light">
|
||||||
|
<item name="android:actionBarStyle">@android:style/Widget.Holo.Light.ActionBar</item>
|
||||||
|
<item name="android:displayOptions">showHome|showTitle|useLogo</item>
|
||||||
|
<item name="android:windowActionBar">true</item>
|
||||||
|
<item name="android:windowNoTitle">false</item>
|
||||||
|
<item name="android:windowSoftInputMode">adjustResize</item>
|
||||||
|
<item name="android:windowContentOverlay">@null</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="NoteActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
|
||||||
|
<item name="android:displayOptions" />
|
||||||
|
<item name="android:visibility">gone</item>
|
||||||
|
</style>
|
||||||
|
</resources>
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<style name="Base.Theme.Notesmaster" parent="Theme.Material3.DayNight.NoActionBar">
|
||||||
|
<!-- Customize your light theme here. -->
|
||||||
|
<!-- <item name="colorPrimary">@color/my_light_primary</item> -->
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="Theme.Notesmaster" parent="Base.Theme.Notesmaster" />
|
||||||
|
</resources>
|
||||||
@ -1,6 +0,0 @@
|
|||||||
Chinese Vosk model for mobile
|
|
||||||
|
|
||||||
CER results
|
|
||||||
|
|
||||||
23.54% speechio_02
|
|
||||||
38.29% speechio_06
|
|
||||||
Binary file not shown.
@ -1,8 +0,0 @@
|
|||||||
--use-energy=false
|
|
||||||
--sample-frequency=16000
|
|
||||||
--num-mel-bins=40
|
|
||||||
--num-ceps=40
|
|
||||||
--low-freq=40
|
|
||||||
--high-freq=-200
|
|
||||||
--allow-upsample=true
|
|
||||||
--allow-downsample=true
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
--min-active=200
|
|
||||||
--max-active=5000
|
|
||||||
--beam=12.0
|
|
||||||
--lattice-beam=4.0
|
|
||||||
--acoustic-scale=1.0
|
|
||||||
--frame-subsampling-factor=3
|
|
||||||
--endpoint.silence-phones=1:2:3:4:5:6:7:8:9:10
|
|
||||||
--endpoint.rule2.min-trailing-silence=0.5
|
|
||||||
--endpoint.rule3.min-trailing-silence=1.0
|
|
||||||
--endpoint.rule4.min-trailing-silence=2.0
|
|
||||||
Binary file not shown.
Binary file not shown.
@ -1,39 +0,0 @@
|
|||||||
11845
|
|
||||||
11846
|
|
||||||
11847
|
|
||||||
11848
|
|
||||||
11849
|
|
||||||
11850
|
|
||||||
11851
|
|
||||||
11852
|
|
||||||
11853
|
|
||||||
11854
|
|
||||||
11855
|
|
||||||
11856
|
|
||||||
11857
|
|
||||||
11858
|
|
||||||
11859
|
|
||||||
11860
|
|
||||||
11861
|
|
||||||
11862
|
|
||||||
11863
|
|
||||||
11864
|
|
||||||
11865
|
|
||||||
11866
|
|
||||||
11867
|
|
||||||
11868
|
|
||||||
11869
|
|
||||||
11870
|
|
||||||
11871
|
|
||||||
11872
|
|
||||||
11873
|
|
||||||
11874
|
|
||||||
11875
|
|
||||||
11876
|
|
||||||
11877
|
|
||||||
11878
|
|
||||||
11879
|
|
||||||
11880
|
|
||||||
11881
|
|
||||||
11882
|
|
||||||
11883
|
|
||||||
@ -1,646 +0,0 @@
|
|||||||
1 nonword
|
|
||||||
2 begin
|
|
||||||
3 end
|
|
||||||
4 internal
|
|
||||||
5 singleton
|
|
||||||
6 nonword
|
|
||||||
7 begin
|
|
||||||
8 end
|
|
||||||
9 internal
|
|
||||||
10 singleton
|
|
||||||
11 begin
|
|
||||||
12 end
|
|
||||||
13 internal
|
|
||||||
14 singleton
|
|
||||||
15 begin
|
|
||||||
16 end
|
|
||||||
17 internal
|
|
||||||
18 singleton
|
|
||||||
19 begin
|
|
||||||
20 end
|
|
||||||
21 internal
|
|
||||||
22 singleton
|
|
||||||
23 begin
|
|
||||||
24 end
|
|
||||||
25 internal
|
|
||||||
26 singleton
|
|
||||||
27 begin
|
|
||||||
28 end
|
|
||||||
29 internal
|
|
||||||
30 singleton
|
|
||||||
31 begin
|
|
||||||
32 end
|
|
||||||
33 internal
|
|
||||||
34 singleton
|
|
||||||
35 begin
|
|
||||||
36 end
|
|
||||||
37 internal
|
|
||||||
38 singleton
|
|
||||||
39 begin
|
|
||||||
40 end
|
|
||||||
41 internal
|
|
||||||
42 singleton
|
|
||||||
43 begin
|
|
||||||
44 end
|
|
||||||
45 internal
|
|
||||||
46 singleton
|
|
||||||
47 begin
|
|
||||||
48 end
|
|
||||||
49 internal
|
|
||||||
50 singleton
|
|
||||||
51 begin
|
|
||||||
52 end
|
|
||||||
53 internal
|
|
||||||
54 singleton
|
|
||||||
55 begin
|
|
||||||
56 end
|
|
||||||
57 internal
|
|
||||||
58 singleton
|
|
||||||
59 begin
|
|
||||||
60 end
|
|
||||||
61 internal
|
|
||||||
62 singleton
|
|
||||||
63 begin
|
|
||||||
64 end
|
|
||||||
65 internal
|
|
||||||
66 singleton
|
|
||||||
67 begin
|
|
||||||
68 end
|
|
||||||
69 internal
|
|
||||||
70 singleton
|
|
||||||
71 begin
|
|
||||||
72 end
|
|
||||||
73 internal
|
|
||||||
74 singleton
|
|
||||||
75 begin
|
|
||||||
76 end
|
|
||||||
77 internal
|
|
||||||
78 singleton
|
|
||||||
79 begin
|
|
||||||
80 end
|
|
||||||
81 internal
|
|
||||||
82 singleton
|
|
||||||
83 begin
|
|
||||||
84 end
|
|
||||||
85 internal
|
|
||||||
86 singleton
|
|
||||||
87 begin
|
|
||||||
88 end
|
|
||||||
89 internal
|
|
||||||
90 singleton
|
|
||||||
91 begin
|
|
||||||
92 end
|
|
||||||
93 internal
|
|
||||||
94 singleton
|
|
||||||
95 begin
|
|
||||||
96 end
|
|
||||||
97 internal
|
|
||||||
98 singleton
|
|
||||||
99 begin
|
|
||||||
100 end
|
|
||||||
101 internal
|
|
||||||
102 singleton
|
|
||||||
103 begin
|
|
||||||
104 end
|
|
||||||
105 internal
|
|
||||||
106 singleton
|
|
||||||
107 begin
|
|
||||||
108 end
|
|
||||||
109 internal
|
|
||||||
110 singleton
|
|
||||||
111 begin
|
|
||||||
112 end
|
|
||||||
113 internal
|
|
||||||
114 singleton
|
|
||||||
115 begin
|
|
||||||
116 end
|
|
||||||
117 internal
|
|
||||||
118 singleton
|
|
||||||
119 begin
|
|
||||||
120 end
|
|
||||||
121 internal
|
|
||||||
122 singleton
|
|
||||||
123 begin
|
|
||||||
124 end
|
|
||||||
125 internal
|
|
||||||
126 singleton
|
|
||||||
127 begin
|
|
||||||
128 end
|
|
||||||
129 internal
|
|
||||||
130 singleton
|
|
||||||
131 begin
|
|
||||||
132 end
|
|
||||||
133 internal
|
|
||||||
134 singleton
|
|
||||||
135 begin
|
|
||||||
136 end
|
|
||||||
137 internal
|
|
||||||
138 singleton
|
|
||||||
139 begin
|
|
||||||
140 end
|
|
||||||
141 internal
|
|
||||||
142 singleton
|
|
||||||
143 begin
|
|
||||||
144 end
|
|
||||||
145 internal
|
|
||||||
146 singleton
|
|
||||||
147 begin
|
|
||||||
148 end
|
|
||||||
149 internal
|
|
||||||
150 singleton
|
|
||||||
151 begin
|
|
||||||
152 end
|
|
||||||
153 internal
|
|
||||||
154 singleton
|
|
||||||
155 begin
|
|
||||||
156 end
|
|
||||||
157 internal
|
|
||||||
158 singleton
|
|
||||||
159 begin
|
|
||||||
160 end
|
|
||||||
161 internal
|
|
||||||
162 singleton
|
|
||||||
163 begin
|
|
||||||
164 end
|
|
||||||
165 internal
|
|
||||||
166 singleton
|
|
||||||
167 begin
|
|
||||||
168 end
|
|
||||||
169 internal
|
|
||||||
170 singleton
|
|
||||||
171 begin
|
|
||||||
172 end
|
|
||||||
173 internal
|
|
||||||
174 singleton
|
|
||||||
175 begin
|
|
||||||
176 end
|
|
||||||
177 internal
|
|
||||||
178 singleton
|
|
||||||
179 begin
|
|
||||||
180 end
|
|
||||||
181 internal
|
|
||||||
182 singleton
|
|
||||||
183 begin
|
|
||||||
184 end
|
|
||||||
185 internal
|
|
||||||
186 singleton
|
|
||||||
187 begin
|
|
||||||
188 end
|
|
||||||
189 internal
|
|
||||||
190 singleton
|
|
||||||
191 begin
|
|
||||||
192 end
|
|
||||||
193 internal
|
|
||||||
194 singleton
|
|
||||||
195 begin
|
|
||||||
196 end
|
|
||||||
197 internal
|
|
||||||
198 singleton
|
|
||||||
199 begin
|
|
||||||
200 end
|
|
||||||
201 internal
|
|
||||||
202 singleton
|
|
||||||
203 begin
|
|
||||||
204 end
|
|
||||||
205 internal
|
|
||||||
206 singleton
|
|
||||||
207 begin
|
|
||||||
208 end
|
|
||||||
209 internal
|
|
||||||
210 singleton
|
|
||||||
211 begin
|
|
||||||
212 end
|
|
||||||
213 internal
|
|
||||||
214 singleton
|
|
||||||
215 begin
|
|
||||||
216 end
|
|
||||||
217 internal
|
|
||||||
218 singleton
|
|
||||||
219 begin
|
|
||||||
220 end
|
|
||||||
221 internal
|
|
||||||
222 singleton
|
|
||||||
223 begin
|
|
||||||
224 end
|
|
||||||
225 internal
|
|
||||||
226 singleton
|
|
||||||
227 begin
|
|
||||||
228 end
|
|
||||||
229 internal
|
|
||||||
230 singleton
|
|
||||||
231 begin
|
|
||||||
232 end
|
|
||||||
233 internal
|
|
||||||
234 singleton
|
|
||||||
235 begin
|
|
||||||
236 end
|
|
||||||
237 internal
|
|
||||||
238 singleton
|
|
||||||
239 begin
|
|
||||||
240 end
|
|
||||||
241 internal
|
|
||||||
242 singleton
|
|
||||||
243 begin
|
|
||||||
244 end
|
|
||||||
245 internal
|
|
||||||
246 singleton
|
|
||||||
247 begin
|
|
||||||
248 end
|
|
||||||
249 internal
|
|
||||||
250 singleton
|
|
||||||
251 begin
|
|
||||||
252 end
|
|
||||||
253 internal
|
|
||||||
254 singleton
|
|
||||||
255 begin
|
|
||||||
256 end
|
|
||||||
257 internal
|
|
||||||
258 singleton
|
|
||||||
259 begin
|
|
||||||
260 end
|
|
||||||
261 internal
|
|
||||||
262 singleton
|
|
||||||
263 begin
|
|
||||||
264 end
|
|
||||||
265 internal
|
|
||||||
266 singleton
|
|
||||||
267 begin
|
|
||||||
268 end
|
|
||||||
269 internal
|
|
||||||
270 singleton
|
|
||||||
271 begin
|
|
||||||
272 end
|
|
||||||
273 internal
|
|
||||||
274 singleton
|
|
||||||
275 begin
|
|
||||||
276 end
|
|
||||||
277 internal
|
|
||||||
278 singleton
|
|
||||||
279 begin
|
|
||||||
280 end
|
|
||||||
281 internal
|
|
||||||
282 singleton
|
|
||||||
283 begin
|
|
||||||
284 end
|
|
||||||
285 internal
|
|
||||||
286 singleton
|
|
||||||
287 begin
|
|
||||||
288 end
|
|
||||||
289 internal
|
|
||||||
290 singleton
|
|
||||||
291 begin
|
|
||||||
292 end
|
|
||||||
293 internal
|
|
||||||
294 singleton
|
|
||||||
295 begin
|
|
||||||
296 end
|
|
||||||
297 internal
|
|
||||||
298 singleton
|
|
||||||
299 begin
|
|
||||||
300 end
|
|
||||||
301 internal
|
|
||||||
302 singleton
|
|
||||||
303 begin
|
|
||||||
304 end
|
|
||||||
305 internal
|
|
||||||
306 singleton
|
|
||||||
307 begin
|
|
||||||
308 end
|
|
||||||
309 internal
|
|
||||||
310 singleton
|
|
||||||
311 begin
|
|
||||||
312 end
|
|
||||||
313 internal
|
|
||||||
314 singleton
|
|
||||||
315 begin
|
|
||||||
316 end
|
|
||||||
317 internal
|
|
||||||
318 singleton
|
|
||||||
319 begin
|
|
||||||
320 end
|
|
||||||
321 internal
|
|
||||||
322 singleton
|
|
||||||
323 begin
|
|
||||||
324 end
|
|
||||||
325 internal
|
|
||||||
326 singleton
|
|
||||||
327 begin
|
|
||||||
328 end
|
|
||||||
329 internal
|
|
||||||
330 singleton
|
|
||||||
331 begin
|
|
||||||
332 end
|
|
||||||
333 internal
|
|
||||||
334 singleton
|
|
||||||
335 begin
|
|
||||||
336 end
|
|
||||||
337 internal
|
|
||||||
338 singleton
|
|
||||||
339 begin
|
|
||||||
340 end
|
|
||||||
341 internal
|
|
||||||
342 singleton
|
|
||||||
343 begin
|
|
||||||
344 end
|
|
||||||
345 internal
|
|
||||||
346 singleton
|
|
||||||
347 begin
|
|
||||||
348 end
|
|
||||||
349 internal
|
|
||||||
350 singleton
|
|
||||||
351 begin
|
|
||||||
352 end
|
|
||||||
353 internal
|
|
||||||
354 singleton
|
|
||||||
355 begin
|
|
||||||
356 end
|
|
||||||
357 internal
|
|
||||||
358 singleton
|
|
||||||
359 begin
|
|
||||||
360 end
|
|
||||||
361 internal
|
|
||||||
362 singleton
|
|
||||||
363 begin
|
|
||||||
364 end
|
|
||||||
365 internal
|
|
||||||
366 singleton
|
|
||||||
367 begin
|
|
||||||
368 end
|
|
||||||
369 internal
|
|
||||||
370 singleton
|
|
||||||
371 begin
|
|
||||||
372 end
|
|
||||||
373 internal
|
|
||||||
374 singleton
|
|
||||||
375 begin
|
|
||||||
376 end
|
|
||||||
377 internal
|
|
||||||
378 singleton
|
|
||||||
379 begin
|
|
||||||
380 end
|
|
||||||
381 internal
|
|
||||||
382 singleton
|
|
||||||
383 begin
|
|
||||||
384 end
|
|
||||||
385 internal
|
|
||||||
386 singleton
|
|
||||||
387 begin
|
|
||||||
388 end
|
|
||||||
389 internal
|
|
||||||
390 singleton
|
|
||||||
391 begin
|
|
||||||
392 end
|
|
||||||
393 internal
|
|
||||||
394 singleton
|
|
||||||
395 begin
|
|
||||||
396 end
|
|
||||||
397 internal
|
|
||||||
398 singleton
|
|
||||||
399 begin
|
|
||||||
400 end
|
|
||||||
401 internal
|
|
||||||
402 singleton
|
|
||||||
403 begin
|
|
||||||
404 end
|
|
||||||
405 internal
|
|
||||||
406 singleton
|
|
||||||
407 begin
|
|
||||||
408 end
|
|
||||||
409 internal
|
|
||||||
410 singleton
|
|
||||||
411 begin
|
|
||||||
412 end
|
|
||||||
413 internal
|
|
||||||
414 singleton
|
|
||||||
415 begin
|
|
||||||
416 end
|
|
||||||
417 internal
|
|
||||||
418 singleton
|
|
||||||
419 begin
|
|
||||||
420 end
|
|
||||||
421 internal
|
|
||||||
422 singleton
|
|
||||||
423 begin
|
|
||||||
424 end
|
|
||||||
425 internal
|
|
||||||
426 singleton
|
|
||||||
427 begin
|
|
||||||
428 end
|
|
||||||
429 internal
|
|
||||||
430 singleton
|
|
||||||
431 begin
|
|
||||||
432 end
|
|
||||||
433 internal
|
|
||||||
434 singleton
|
|
||||||
435 begin
|
|
||||||
436 end
|
|
||||||
437 internal
|
|
||||||
438 singleton
|
|
||||||
439 begin
|
|
||||||
440 end
|
|
||||||
441 internal
|
|
||||||
442 singleton
|
|
||||||
443 begin
|
|
||||||
444 end
|
|
||||||
445 internal
|
|
||||||
446 singleton
|
|
||||||
447 begin
|
|
||||||
448 end
|
|
||||||
449 internal
|
|
||||||
450 singleton
|
|
||||||
451 begin
|
|
||||||
452 end
|
|
||||||
453 internal
|
|
||||||
454 singleton
|
|
||||||
455 begin
|
|
||||||
456 end
|
|
||||||
457 internal
|
|
||||||
458 singleton
|
|
||||||
459 begin
|
|
||||||
460 end
|
|
||||||
461 internal
|
|
||||||
462 singleton
|
|
||||||
463 begin
|
|
||||||
464 end
|
|
||||||
465 internal
|
|
||||||
466 singleton
|
|
||||||
467 begin
|
|
||||||
468 end
|
|
||||||
469 internal
|
|
||||||
470 singleton
|
|
||||||
471 begin
|
|
||||||
472 end
|
|
||||||
473 internal
|
|
||||||
474 singleton
|
|
||||||
475 begin
|
|
||||||
476 end
|
|
||||||
477 internal
|
|
||||||
478 singleton
|
|
||||||
479 begin
|
|
||||||
480 end
|
|
||||||
481 internal
|
|
||||||
482 singleton
|
|
||||||
483 begin
|
|
||||||
484 end
|
|
||||||
485 internal
|
|
||||||
486 singleton
|
|
||||||
487 begin
|
|
||||||
488 end
|
|
||||||
489 internal
|
|
||||||
490 singleton
|
|
||||||
491 begin
|
|
||||||
492 end
|
|
||||||
493 internal
|
|
||||||
494 singleton
|
|
||||||
495 begin
|
|
||||||
496 end
|
|
||||||
497 internal
|
|
||||||
498 singleton
|
|
||||||
499 begin
|
|
||||||
500 end
|
|
||||||
501 internal
|
|
||||||
502 singleton
|
|
||||||
503 begin
|
|
||||||
504 end
|
|
||||||
505 internal
|
|
||||||
506 singleton
|
|
||||||
507 begin
|
|
||||||
508 end
|
|
||||||
509 internal
|
|
||||||
510 singleton
|
|
||||||
511 begin
|
|
||||||
512 end
|
|
||||||
513 internal
|
|
||||||
514 singleton
|
|
||||||
515 begin
|
|
||||||
516 end
|
|
||||||
517 internal
|
|
||||||
518 singleton
|
|
||||||
519 begin
|
|
||||||
520 end
|
|
||||||
521 internal
|
|
||||||
522 singleton
|
|
||||||
523 begin
|
|
||||||
524 end
|
|
||||||
525 internal
|
|
||||||
526 singleton
|
|
||||||
527 begin
|
|
||||||
528 end
|
|
||||||
529 internal
|
|
||||||
530 singleton
|
|
||||||
531 begin
|
|
||||||
532 end
|
|
||||||
533 internal
|
|
||||||
534 singleton
|
|
||||||
535 begin
|
|
||||||
536 end
|
|
||||||
537 internal
|
|
||||||
538 singleton
|
|
||||||
539 begin
|
|
||||||
540 end
|
|
||||||
541 internal
|
|
||||||
542 singleton
|
|
||||||
543 begin
|
|
||||||
544 end
|
|
||||||
545 internal
|
|
||||||
546 singleton
|
|
||||||
547 begin
|
|
||||||
548 end
|
|
||||||
549 internal
|
|
||||||
550 singleton
|
|
||||||
551 begin
|
|
||||||
552 end
|
|
||||||
553 internal
|
|
||||||
554 singleton
|
|
||||||
555 begin
|
|
||||||
556 end
|
|
||||||
557 internal
|
|
||||||
558 singleton
|
|
||||||
559 begin
|
|
||||||
560 end
|
|
||||||
561 internal
|
|
||||||
562 singleton
|
|
||||||
563 begin
|
|
||||||
564 end
|
|
||||||
565 internal
|
|
||||||
566 singleton
|
|
||||||
567 begin
|
|
||||||
568 end
|
|
||||||
569 internal
|
|
||||||
570 singleton
|
|
||||||
571 begin
|
|
||||||
572 end
|
|
||||||
573 internal
|
|
||||||
574 singleton
|
|
||||||
575 begin
|
|
||||||
576 end
|
|
||||||
577 internal
|
|
||||||
578 singleton
|
|
||||||
579 begin
|
|
||||||
580 end
|
|
||||||
581 internal
|
|
||||||
582 singleton
|
|
||||||
583 begin
|
|
||||||
584 end
|
|
||||||
585 internal
|
|
||||||
586 singleton
|
|
||||||
587 begin
|
|
||||||
588 end
|
|
||||||
589 internal
|
|
||||||
590 singleton
|
|
||||||
591 begin
|
|
||||||
592 end
|
|
||||||
593 internal
|
|
||||||
594 singleton
|
|
||||||
595 begin
|
|
||||||
596 end
|
|
||||||
597 internal
|
|
||||||
598 singleton
|
|
||||||
599 begin
|
|
||||||
600 end
|
|
||||||
601 internal
|
|
||||||
602 singleton
|
|
||||||
603 begin
|
|
||||||
604 end
|
|
||||||
605 internal
|
|
||||||
606 singleton
|
|
||||||
607 begin
|
|
||||||
608 end
|
|
||||||
609 internal
|
|
||||||
610 singleton
|
|
||||||
611 begin
|
|
||||||
612 end
|
|
||||||
613 internal
|
|
||||||
614 singleton
|
|
||||||
615 begin
|
|
||||||
616 end
|
|
||||||
617 internal
|
|
||||||
618 singleton
|
|
||||||
619 begin
|
|
||||||
620 end
|
|
||||||
621 internal
|
|
||||||
622 singleton
|
|
||||||
623 begin
|
|
||||||
624 end
|
|
||||||
625 internal
|
|
||||||
626 singleton
|
|
||||||
627 begin
|
|
||||||
628 end
|
|
||||||
629 internal
|
|
||||||
630 singleton
|
|
||||||
631 begin
|
|
||||||
632 end
|
|
||||||
633 internal
|
|
||||||
634 singleton
|
|
||||||
635 begin
|
|
||||||
636 end
|
|
||||||
637 internal
|
|
||||||
638 singleton
|
|
||||||
639 begin
|
|
||||||
640 end
|
|
||||||
641 internal
|
|
||||||
642 singleton
|
|
||||||
643 begin
|
|
||||||
644 end
|
|
||||||
645 internal
|
|
||||||
646 singleton
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,3 +0,0 @@
|
|||||||
[
|
|
||||||
1.117107e+11 -7.827721e+08 -1.101398e+10 -2.193934e+09 -1.347332e+10 -1.613916e+10 -1.199561e+10 -1.255081e+10 -1.638895e+10 -3.821099e+09 -1.372833e+10 -5.244242e+09 -1.098187e+10 -3.655235e+09 -9.364579e+09 -4.285302e+09 -6.296873e+09 -1.552953e+09 -3.176746e+09 -1.202976e+08 -9.857023e+08 2.316555e+08 -1.61059e+08 -5.891868e+07 3.465849e+08 -1.842054e+08 3.248211e+08 -1.483965e+08 3.739239e+08 -6.672061e+08 4.442288e+08 -9.274889e+08 5.142684e+08 4.292036e+07 2.206386e+08 -4.532715e+08 -2.092499e+08 -3.70488e+08 -8.079404e+07 -8.425977e+07 1.344125e+09
|
|
||||||
9.982632e+12 1.02635e+12 8.634624e+11 9.06451e+11 9.652096e+11 1.12772e+12 9.468372e+11 9.141218e+11 9.670484e+11 6.936961e+11 8.141006e+11 6.256321e+11 6.087707e+11 4.616898e+11 4.212042e+11 2.862872e+11 2.498089e+11 1.470856e+11 1.099197e+11 5.780894e+10 3.118114e+10 1.060667e+10 1.466199e+09 4.173056e+08 5.257362e+09 1.277714e+10 2.114478e+10 2.974502e+10 3.587691e+10 4.078971e+10 4.247745e+10 4.382608e+10 4.62521e+10 4.575282e+10 3.546206e+10 3.041531e+10 2.838562e+10 2.258604e+10 1.715295e+10 1.303227e+10 0 ]
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
--left-context=3
|
|
||||||
--right-context=3
|
|
||||||
@ -0,0 +1,62 @@
|
|||||||
|
package net.micode.notes.vosk;
|
||||||
|
|
||||||
|
import com.sun.jna.Native;
|
||||||
|
import com.sun.jna.Library;
|
||||||
|
import com.sun.jna.Platform;
|
||||||
|
import com.sun.jna.Pointer;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
|
|
||||||
|
public class LibVosk {
|
||||||
|
|
||||||
|
static {
|
||||||
|
Native.register(LibVosk.class, "vosk");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static native void vosk_set_log_level(int level);
|
||||||
|
|
||||||
|
public static native Pointer vosk_model_new(String path);
|
||||||
|
|
||||||
|
public static native void vosk_model_free(Pointer model);
|
||||||
|
|
||||||
|
public static native Pointer vosk_spk_model_new(String path);
|
||||||
|
|
||||||
|
public static native void vosk_spk_model_free(Pointer model);
|
||||||
|
|
||||||
|
public static native Pointer vosk_recognizer_new(Model model, float sample_rate);
|
||||||
|
|
||||||
|
public static native Pointer vosk_recognizer_new_spk(Pointer model, float sample_rate, Pointer spk_model);
|
||||||
|
|
||||||
|
public static native Pointer vosk_recognizer_new_grm(Pointer model, float sample_rate, String grammar);
|
||||||
|
|
||||||
|
public static native void vosk_recognizer_set_max_alternatives(Pointer recognizer, int max_alternatives);
|
||||||
|
|
||||||
|
public static native void vosk_recognizer_set_words(Pointer recognizer, boolean words);
|
||||||
|
|
||||||
|
public static native void vosk_recognizer_set_partial_words(Pointer recognizer, boolean partial_words);
|
||||||
|
|
||||||
|
public static native void vosk_recognizer_set_spk_model(Pointer recognizer, Pointer spk_model);
|
||||||
|
|
||||||
|
public static native boolean vosk_recognizer_accept_waveform(Pointer recognizer, byte[] data, int len);
|
||||||
|
|
||||||
|
public static native boolean vosk_recognizer_accept_waveform_s(Pointer recognizer, short[] data, int len);
|
||||||
|
|
||||||
|
public static native boolean vosk_recognizer_accept_waveform_f(Pointer recognizer, float[] data, int len);
|
||||||
|
|
||||||
|
public static native String vosk_recognizer_result(Pointer recognizer);
|
||||||
|
|
||||||
|
public static native String vosk_recognizer_final_result(Pointer recognizer);
|
||||||
|
|
||||||
|
public static native String vosk_recognizer_partial_result(Pointer recognizer);
|
||||||
|
|
||||||
|
public static native void vosk_recognizer_reset(Pointer recognizer);
|
||||||
|
|
||||||
|
public static native void vosk_recognizer_free(Pointer recognizer);
|
||||||
|
|
||||||
|
public static void setLogLevel(LogLevel loglevel) {
|
||||||
|
vosk_set_log_level(loglevel.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
package net.micode.notes.vosk;
|
||||||
|
|
||||||
|
public enum LogLevel {
|
||||||
|
WARNINGS(-1), // Print warning and errors
|
||||||
|
INFO(0), // Print info, along with warning and error messages, but no debug
|
||||||
|
DEBUG(1); // Print debug info
|
||||||
|
|
||||||
|
private final int value;
|
||||||
|
|
||||||
|
LogLevel(int value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
package net.micode.notes.vosk;
|
||||||
|
|
||||||
|
import com.sun.jna.PointerType;
|
||||||
|
|
||||||
|
public class Model extends PointerType implements AutoCloseable {
|
||||||
|
public Model() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Model(String path) {
|
||||||
|
super(LibVosk.vosk_model_new(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
LibVosk.vosk_model_free(this.getPointer());
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,66 @@
|
|||||||
|
package net.micode.notes.vosk;
|
||||||
|
|
||||||
|
import com.sun.jna.PointerType;
|
||||||
|
|
||||||
|
public class Recognizer extends PointerType implements AutoCloseable {
|
||||||
|
public Recognizer(Model model, float sampleRate) {
|
||||||
|
super(LibVosk.vosk_recognizer_new(model, sampleRate));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Recognizer(Model model, float sampleRate, SpeakerModel spkModel) {
|
||||||
|
super(LibVosk.vosk_recognizer_new_spk(model.getPointer(), sampleRate, spkModel.getPointer()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Recognizer(Model model, float sampleRate, String grammar) {
|
||||||
|
super(LibVosk.vosk_recognizer_new_grm(model.getPointer(), sampleRate, grammar));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxAlternatives(int maxAlternatives) {
|
||||||
|
LibVosk.vosk_recognizer_set_max_alternatives(this.getPointer(), maxAlternatives);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWords(boolean words) {
|
||||||
|
LibVosk.vosk_recognizer_set_words(this.getPointer(), words);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPartialWords(boolean partial_words) {
|
||||||
|
LibVosk.vosk_recognizer_set_partial_words(this.getPointer(), partial_words);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpeakerModel(SpeakerModel spkModel) {
|
||||||
|
LibVosk.vosk_recognizer_set_spk_model(this.getPointer(), spkModel.getPointer());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean acceptWaveForm(byte[] data, int len) {
|
||||||
|
return LibVosk.vosk_recognizer_accept_waveform(this.getPointer(), data, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean acceptWaveForm(short[] data, int len) {
|
||||||
|
return LibVosk.vosk_recognizer_accept_waveform_s(this.getPointer(), data, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean acceptWaveForm(float[] data, int len) {
|
||||||
|
return LibVosk.vosk_recognizer_accept_waveform_f(this.getPointer(), data, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getResult() {
|
||||||
|
return LibVosk.vosk_recognizer_result(this.getPointer());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPartialResult() {
|
||||||
|
return LibVosk.vosk_recognizer_partial_result(this.getPointer());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFinalResult() {
|
||||||
|
return LibVosk.vosk_recognizer_final_result(this.getPointer());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
LibVosk.vosk_recognizer_reset(this.getPointer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
LibVosk.vosk_recognizer_free(this.getPointer());
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
package net.micode.notes.vosk;
|
||||||
|
|
||||||
|
import com.sun.jna.PointerType;
|
||||||
|
|
||||||
|
public class SpeakerModel extends PointerType implements AutoCloseable {
|
||||||
|
public SpeakerModel() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public SpeakerModel(String path) {
|
||||||
|
super(LibVosk.vosk_spk_model_new(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
LibVosk.vosk_spk_model_free(this.getPointer());
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
// Copyright 2019 Alpha Cephei Inc.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package net.micode.notes.vosk.android;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface to receive recognition results
|
||||||
|
*/
|
||||||
|
public interface RecognitionListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when partial recognition result is available.
|
||||||
|
*/
|
||||||
|
void onPartialResult(String hypothesis);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called after silence occured.
|
||||||
|
*/
|
||||||
|
void onResult(String hypothesis);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called after stream end.
|
||||||
|
*/
|
||||||
|
void onFinalResult(String hypothesis);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an error occurs.
|
||||||
|
*/
|
||||||
|
void onError(Exception exception);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called after timeout expired
|
||||||
|
*/
|
||||||
|
void onTimeout();
|
||||||
|
}
|
||||||
@ -0,0 +1,257 @@
|
|||||||
|
// Copyright 2019 Alpha Cephei Inc.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package net.micode.notes.vosk.android;
|
||||||
|
|
||||||
|
import android.media.AudioFormat;
|
||||||
|
import android.media.AudioRecord;
|
||||||
|
import android.media.MediaRecorder.AudioSource;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
|
||||||
|
import net.micode.notes.vosk.Recognizer;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Service that records audio in a thread, passes it to a recognizer and emits
|
||||||
|
* recognition results. Recognition events are passed to a client using
|
||||||
|
* {@link RecognitionListener}
|
||||||
|
*/
|
||||||
|
public class SpeechService {
|
||||||
|
|
||||||
|
private final Recognizer recognizer;
|
||||||
|
|
||||||
|
private final int sampleRate;
|
||||||
|
private final static float BUFFER_SIZE_SECONDS = 0.2f;
|
||||||
|
private final int bufferSize;
|
||||||
|
private final AudioRecord recorder;
|
||||||
|
|
||||||
|
private RecognizerThread recognizerThread;
|
||||||
|
|
||||||
|
private final Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates speech service. Service holds the AudioRecord object, so you
|
||||||
|
* need to call {@link #shutdown()} in order to properly finalize it.
|
||||||
|
*
|
||||||
|
* @throws IOException thrown if audio recorder can not be created for some reason.
|
||||||
|
*/
|
||||||
|
public SpeechService(Recognizer recognizer, float sampleRate) throws IOException {
|
||||||
|
this.recognizer = recognizer;
|
||||||
|
this.sampleRate = (int) sampleRate;
|
||||||
|
|
||||||
|
bufferSize = Math.round(this.sampleRate * BUFFER_SIZE_SECONDS);
|
||||||
|
recorder = new AudioRecord(
|
||||||
|
AudioSource.VOICE_RECOGNITION, this.sampleRate,
|
||||||
|
AudioFormat.CHANNEL_IN_MONO,
|
||||||
|
AudioFormat.ENCODING_PCM_16BIT, bufferSize * 2);
|
||||||
|
|
||||||
|
if (recorder.getState() == AudioRecord.STATE_UNINITIALIZED) {
|
||||||
|
recorder.release();
|
||||||
|
throw new IOException(
|
||||||
|
"Failed to initialize recorder. Microphone might be already in use.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts recognition. Does nothing if recognition is active.
|
||||||
|
*
|
||||||
|
* @return true if recognition was actually started
|
||||||
|
*/
|
||||||
|
public boolean startListening(RecognitionListener listener) {
|
||||||
|
if (null != recognizerThread)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
recognizerThread = new RecognizerThread(listener);
|
||||||
|
recognizerThread.start();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts recognition. After specified timeout listening stops and the
|
||||||
|
* endOfSpeech signals about that. Does nothing if recognition is active.
|
||||||
|
* <p>
|
||||||
|
* timeout - timeout in milliseconds to listen.
|
||||||
|
*
|
||||||
|
* @return true if recognition was actually started
|
||||||
|
*/
|
||||||
|
public boolean startListening(RecognitionListener listener, int timeout) {
|
||||||
|
if (null != recognizerThread)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
recognizerThread = new RecognizerThread(listener, timeout);
|
||||||
|
recognizerThread.start();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean stopRecognizerThread() {
|
||||||
|
if (null == recognizerThread)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
recognizerThread.interrupt();
|
||||||
|
recognizerThread.join();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// Restore the interrupted status.
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
|
||||||
|
recognizerThread = null;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stops recognition. Listener should receive final result if there is
|
||||||
|
* any. Does nothing if recognition is not active.
|
||||||
|
*
|
||||||
|
* @return true if recognition was actually stopped
|
||||||
|
*/
|
||||||
|
public boolean stop() {
|
||||||
|
return stopRecognizerThread();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancel recognition. Do not post any new events, simply cancel processing.
|
||||||
|
* Does nothing if recognition is not active.
|
||||||
|
*
|
||||||
|
* @return true if recognition was actually stopped
|
||||||
|
*/
|
||||||
|
public boolean cancel() {
|
||||||
|
if (recognizerThread != null) {
|
||||||
|
recognizerThread.setPause(true);
|
||||||
|
}
|
||||||
|
return stopRecognizerThread();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shutdown the recognizer and release the recorder
|
||||||
|
*/
|
||||||
|
public void shutdown() {
|
||||||
|
recorder.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPause(boolean paused) {
|
||||||
|
if (recognizerThread != null) {
|
||||||
|
recognizerThread.setPause(paused);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets recognizer in a thread, starts recognition over again
|
||||||
|
*/
|
||||||
|
public void reset() {
|
||||||
|
if (recognizerThread != null) {
|
||||||
|
recognizerThread.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final class RecognizerThread extends Thread {
|
||||||
|
|
||||||
|
private int remainingSamples;
|
||||||
|
private final int timeoutSamples;
|
||||||
|
private final static int NO_TIMEOUT = -1;
|
||||||
|
private volatile boolean paused = false;
|
||||||
|
private volatile boolean reset = false;
|
||||||
|
|
||||||
|
RecognitionListener listener;
|
||||||
|
|
||||||
|
public RecognizerThread(RecognitionListener listener, int timeout) {
|
||||||
|
this.listener = listener;
|
||||||
|
if (timeout != NO_TIMEOUT)
|
||||||
|
this.timeoutSamples = timeout * sampleRate / 1000;
|
||||||
|
else
|
||||||
|
this.timeoutSamples = NO_TIMEOUT;
|
||||||
|
this.remainingSamples = this.timeoutSamples;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RecognizerThread(RecognitionListener listener) {
|
||||||
|
this(listener, NO_TIMEOUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When we are paused, don't process audio by the recognizer and don't emit
|
||||||
|
* any listener results
|
||||||
|
*
|
||||||
|
* @param paused the status of pause
|
||||||
|
*/
|
||||||
|
public void setPause(boolean paused) {
|
||||||
|
this.paused = paused;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set reset state to signal reset of the recognizer and start over
|
||||||
|
*/
|
||||||
|
public void reset() {
|
||||||
|
this.reset = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
recorder.startRecording();
|
||||||
|
if (recorder.getRecordingState() == AudioRecord.RECORDSTATE_STOPPED) {
|
||||||
|
recorder.stop();
|
||||||
|
IOException ioe = new IOException(
|
||||||
|
"Failed to start recording. Microphone might be already in use.");
|
||||||
|
mainHandler.post(() -> listener.onError(ioe));
|
||||||
|
}
|
||||||
|
|
||||||
|
short[] buffer = new short[bufferSize];
|
||||||
|
|
||||||
|
while (!interrupted()
|
||||||
|
&& ((timeoutSamples == NO_TIMEOUT) || (remainingSamples > 0))) {
|
||||||
|
int nread = recorder.read(buffer, 0, buffer.length);
|
||||||
|
|
||||||
|
if (paused) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reset) {
|
||||||
|
recognizer.reset();
|
||||||
|
reset = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nread < 0)
|
||||||
|
throw new RuntimeException("error reading audio buffer");
|
||||||
|
|
||||||
|
if (recognizer.acceptWaveForm(buffer, nread)) {
|
||||||
|
final String result = recognizer.getResult();
|
||||||
|
mainHandler.post(() -> listener.onResult(result));
|
||||||
|
} else {
|
||||||
|
final String partialResult = recognizer.getPartialResult();
|
||||||
|
mainHandler.post(() -> listener.onPartialResult(partialResult));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (timeoutSamples != NO_TIMEOUT) {
|
||||||
|
remainingSamples = remainingSamples - nread;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
recorder.stop();
|
||||||
|
|
||||||
|
if (!paused) {
|
||||||
|
// If we met timeout signal that speech ended
|
||||||
|
if (timeoutSamples != NO_TIMEOUT && remainingSamples <= 0) {
|
||||||
|
mainHandler.post(() -> listener.onTimeout());
|
||||||
|
} else {
|
||||||
|
final String finalResult = recognizer.getFinalResult();
|
||||||
|
mainHandler.post(() -> listener.onFinalResult(finalResult));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,165 @@
|
|||||||
|
// Copyright 2019 Alpha Cephei Inc.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package net.micode.notes.vosk.android;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
|
||||||
|
import net.micode.notes.vosk.Recognizer;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Service that recognizes stream audio in a thread, passes it to a recognizer and emits
|
||||||
|
* recognition results. Recognition events are passed to a client using
|
||||||
|
* {@link RecognitionListener}
|
||||||
|
*/
|
||||||
|
public class SpeechStreamService {
|
||||||
|
|
||||||
|
private final Recognizer recognizer;
|
||||||
|
private final InputStream inputStream;
|
||||||
|
private final int sampleRate;
|
||||||
|
private final static float BUFFER_SIZE_SECONDS = 0.2f;
|
||||||
|
private final int bufferSize;
|
||||||
|
|
||||||
|
private Thread recognizerThread;
|
||||||
|
|
||||||
|
private final Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates speech service.
|
||||||
|
**/
|
||||||
|
public SpeechStreamService(Recognizer recognizer, InputStream inputStream, float sampleRate) {
|
||||||
|
this.recognizer = recognizer;
|
||||||
|
this.sampleRate = (int) sampleRate;
|
||||||
|
this.inputStream = inputStream;
|
||||||
|
bufferSize = Math.round(this.sampleRate * BUFFER_SIZE_SECONDS * 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts recognition. Does nothing if recognition is active.
|
||||||
|
*
|
||||||
|
* @return true if recognition was actually started
|
||||||
|
*/
|
||||||
|
public boolean start(RecognitionListener listener) {
|
||||||
|
if (null != recognizerThread)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
recognizerThread = new RecognizerThread(listener);
|
||||||
|
recognizerThread.start();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts recognition. After specified timeout listening stops and the
|
||||||
|
* endOfSpeech signals about that. Does nothing if recognition is active.
|
||||||
|
* <p>
|
||||||
|
* timeout - timeout in milliseconds to listen.
|
||||||
|
*
|
||||||
|
* @return true if recognition was actually started
|
||||||
|
*/
|
||||||
|
public boolean start(RecognitionListener listener, int timeout) {
|
||||||
|
if (null != recognizerThread)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
recognizerThread = new RecognizerThread(listener, timeout);
|
||||||
|
recognizerThread.start();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stops recognition. All listeners should receive final result if there is
|
||||||
|
* any. Does nothing if recognition is not active.
|
||||||
|
*
|
||||||
|
* @return true if recognition was actually stopped
|
||||||
|
*/
|
||||||
|
public boolean stop() {
|
||||||
|
if (null == recognizerThread)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
recognizerThread.interrupt();
|
||||||
|
recognizerThread.join();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// Restore the interrupted status.
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
|
||||||
|
recognizerThread = null;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final class RecognizerThread extends Thread {
|
||||||
|
|
||||||
|
private int remainingSamples;
|
||||||
|
private final int timeoutSamples;
|
||||||
|
private final static int NO_TIMEOUT = -1;
|
||||||
|
RecognitionListener listener;
|
||||||
|
|
||||||
|
public RecognizerThread(RecognitionListener listener, int timeout) {
|
||||||
|
this.listener = listener;
|
||||||
|
if (timeout != NO_TIMEOUT)
|
||||||
|
this.timeoutSamples = timeout * sampleRate / 1000;
|
||||||
|
else
|
||||||
|
this.timeoutSamples = NO_TIMEOUT;
|
||||||
|
this.remainingSamples = this.timeoutSamples;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RecognizerThread(RecognitionListener listener) {
|
||||||
|
this(listener, NO_TIMEOUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
byte[] buffer = new byte[bufferSize];
|
||||||
|
|
||||||
|
while (!interrupted()
|
||||||
|
&& ((timeoutSamples == NO_TIMEOUT) || (remainingSamples > 0))) {
|
||||||
|
try {
|
||||||
|
int nread = inputStream.read(buffer, 0, buffer.length);
|
||||||
|
if (nread < 0) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
boolean isSilence = recognizer.acceptWaveForm(buffer, nread);
|
||||||
|
if (isSilence) {
|
||||||
|
final String result = recognizer.getResult();
|
||||||
|
mainHandler.post(() -> listener.onResult(result));
|
||||||
|
} else {
|
||||||
|
final String partialResult = recognizer.getPartialResult();
|
||||||
|
mainHandler.post(() -> listener.onPartialResult(partialResult));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (timeoutSamples != NO_TIMEOUT) {
|
||||||
|
remainingSamples = remainingSamples - nread;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
mainHandler.post(() -> listener.onError(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we met timeout signal that speech ended
|
||||||
|
if (timeoutSamples != NO_TIMEOUT && remainingSamples <= 0) {
|
||||||
|
mainHandler.post(() -> listener.onTimeout());
|
||||||
|
} else {
|
||||||
|
final String finalResult = recognizer.getFinalResult();
|
||||||
|
mainHandler.post(() -> listener.onFinalResult(finalResult));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,150 @@
|
|||||||
|
// Copyright 2019 Alpha Cephei Inc.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package net.micode.notes.vosk.android;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.AssetManager;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import net.micode.notes.vosk.Model;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides utility methods to sync model files to external storage to allow
|
||||||
|
* C++ code access them. Relies on file named "uuid" to track updates.
|
||||||
|
*/
|
||||||
|
public class StorageService {
|
||||||
|
|
||||||
|
protected static final String TAG = StorageService.class.getSimpleName();
|
||||||
|
|
||||||
|
public interface Callback<R> {
|
||||||
|
void onComplete(R result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void unpack(Context context, String sourcePath, final String targetPath, final Callback<Model> completeCallback, final Callback<IOException> errorCallback) {
|
||||||
|
Executor executor = Executors.newSingleThreadExecutor(); // change according to your requirements
|
||||||
|
Handler handler = new Handler(Looper.getMainLooper());
|
||||||
|
executor.execute(() -> {
|
||||||
|
try {
|
||||||
|
final String outputPath = sync(context, sourcePath, targetPath);
|
||||||
|
Model model = new Model(outputPath);
|
||||||
|
handler.post(() -> completeCallback.onComplete(model));
|
||||||
|
} catch (final IOException e) {
|
||||||
|
handler.post(() -> errorCallback.onComplete(e));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String sync(Context context, String sourcePath, String targetPath) throws IOException {
|
||||||
|
|
||||||
|
AssetManager assetManager = context.getAssets();
|
||||||
|
|
||||||
|
File externalFilesDir = context.getExternalFilesDir(null);
|
||||||
|
if (externalFilesDir == null) {
|
||||||
|
throw new IOException("cannot get external files dir, "
|
||||||
|
+ "external storage state is " + Environment.getExternalStorageState());
|
||||||
|
}
|
||||||
|
|
||||||
|
File targetDir = new File(externalFilesDir, targetPath);
|
||||||
|
String resultPath = new File(targetDir, sourcePath).getAbsolutePath();
|
||||||
|
String sourceUUID = readLine(assetManager.open(sourcePath + "/uuid"));
|
||||||
|
try {
|
||||||
|
String targetUUID = readLine(new FileInputStream(new File(targetDir, sourcePath + "/uuid")));
|
||||||
|
if (targetUUID.equals(sourceUUID)) return resultPath;
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
deleteContents(targetDir);
|
||||||
|
|
||||||
|
copyAssets(assetManager, sourcePath, targetDir);
|
||||||
|
|
||||||
|
// Copy uuid
|
||||||
|
copyFile(assetManager, sourcePath + "/uuid", targetDir);
|
||||||
|
|
||||||
|
return resultPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String readLine(InputStream is) throws IOException {
|
||||||
|
return new BufferedReader(new InputStreamReader(is)).readLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean deleteContents(File dir) {
|
||||||
|
File[] files = dir.listFiles();
|
||||||
|
boolean success = true;
|
||||||
|
if (files != null) {
|
||||||
|
for (File file : files) {
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
success &= deleteContents(file);
|
||||||
|
}
|
||||||
|
if (!file.delete()) {
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void copyAssets(AssetManager assetManager, String path, File outPath) throws IOException {
|
||||||
|
String[] assets = assetManager.list(path);
|
||||||
|
if (assets == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (assets.length == 0) {
|
||||||
|
if (!path.endsWith("uuid"))
|
||||||
|
copyFile(assetManager, path, outPath);
|
||||||
|
} else {
|
||||||
|
File dir = new File(outPath, path);
|
||||||
|
if (!dir.exists()) {
|
||||||
|
Log.v(TAG, "Making directory " + dir.getAbsolutePath());
|
||||||
|
if (!dir.mkdirs()) {
|
||||||
|
Log.v(TAG, "Failed to create directory " + dir.getAbsolutePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (String asset : assets) {
|
||||||
|
copyAssets(assetManager, path + "/" + asset, outPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void copyFile(AssetManager assetManager, String fileName, File outPath) throws IOException {
|
||||||
|
InputStream in;
|
||||||
|
|
||||||
|
Log.v(TAG, "Copy " + fileName + " to " + outPath);
|
||||||
|
in = assetManager.open(fileName);
|
||||||
|
OutputStream out = new FileOutputStream(outPath + "/" + fileName);
|
||||||
|
|
||||||
|
byte[] buffer = new byte[4000];
|
||||||
|
int read;
|
||||||
|
while ((read = in.read(buffer)) != -1) {
|
||||||
|
out.write(buffer, 0, read);
|
||||||
|
}
|
||||||
|
in.close();
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in new issue