pvleopard 1.1.4__py3-none-any.whl → 1.2.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
pvleopard/__init__.py CHANGED
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2022 Picovoice Inc.
2
+ # Copyright 2022-2023 Picovoice Inc.
3
3
  #
4
4
  # You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE"
5
5
  # file accompanying this source.
@@ -9,36 +9,6 @@
9
9
  # specific language governing permissions and limitations under the License.
10
10
  #
11
11
 
12
- from typing import *
13
-
14
- from .leopard import *
15
- from .util import *
16
-
17
-
18
- def create(
19
- access_key: str,
20
- model_path: Optional[str] = None,
21
- library_path: Optional[str] = None,
22
- enable_automatic_punctuation: bool = False) -> Leopard:
23
- """
24
- Factory method for Leopard speech-to-text engine.
25
-
26
- :param access_key: AccessKey obtained from Picovoice Console (https://console.picovoice.ai/)
27
- :param library_path: Absolute path to Leopard's dynamic library. If not set it will be set to the default location.
28
- :param model_path: Absolute path to the file containing model parameters. If not set it will be set to the default
29
- location.
30
- :param enable_automatic_punctuation Set to `True` to enable automatic punctuation insertion.
31
- :return: An instance of Leopard speech-to-text engine.
32
- """
33
-
34
- if model_path is None:
35
- model_path = default_model_path('')
36
-
37
- if library_path is None:
38
- library_path = default_library_path('')
39
-
40
- return Leopard(
41
- access_key=access_key,
42
- model_path=model_path,
43
- library_path=library_path,
44
- enable_automatic_punctuation=enable_automatic_punctuation)
12
+ from ._factory import *
13
+ from ._leopard import *
14
+ from ._util import *
pvleopard/_factory.py ADDED
@@ -0,0 +1,49 @@
1
+ #
2
+ # Copyright 2023 Picovoice Inc.
3
+ #
4
+ # You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE"
5
+ # file accompanying this source.
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
8
+ # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
9
+ # specific language governing permissions and limitations under the License.
10
+ #
11
+
12
+ from typing import *
13
+
14
+ from ._leopard import Leopard
15
+ from ._util import default_library_path, default_model_path
16
+
17
+
18
+ def create(
19
+ access_key: str,
20
+ model_path: Optional[str] = None,
21
+ library_path: Optional[str] = None,
22
+ enable_automatic_punctuation: bool = False) -> Leopard:
23
+ """
24
+ Factory method for Leopard speech-to-text engine.
25
+
26
+ :param access_key: AccessKey obtained from Picovoice Console (https://console.picovoice.ai/)
27
+ :param library_path: Absolute path to Leopard's dynamic library. If not set it will be set to the default location.
28
+ :param model_path: Absolute path to the file containing model parameters. If not set it will be set to the default
29
+ location.
30
+ :param enable_automatic_punctuation Set to `True` to enable automatic punctuation insertion.
31
+ :return: An instance of Leopard speech-to-text engine.
32
+ """
33
+
34
+ if model_path is None:
35
+ model_path = default_model_path('')
36
+
37
+ if library_path is None:
38
+ library_path = default_library_path('')
39
+
40
+ return Leopard(
41
+ access_key=access_key,
42
+ model_path=model_path,
43
+ library_path=library_path,
44
+ enable_automatic_punctuation=enable_automatic_punctuation)
45
+
46
+
47
+ __all__ = [
48
+ 'create',
49
+ ]
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2018-2022 Picovoice Inc.
2
+ # Copyright 2018-2023 Picovoice Inc.
3
3
  #
4
4
  # You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE"
5
5
  # file accompanying this source.
@@ -189,9 +189,17 @@ class Leopard(object):
189
189
 
190
190
  self._sample_rate = library.pv_sample_rate()
191
191
 
192
- self._pv_free = library.pv_free
193
- self._pv_free.argtypes = [c_void_p]
194
- self._pv_free.restype = None
192
+ self._transcript_delete_func = library.pv_leopard_transcript_delete
193
+ self._transcript_delete_func.argtypes = [
194
+ c_char_p
195
+ ]
196
+ self._transcript_delete_func.restype = None
197
+
198
+ self._words_delete_func = library.pv_leopard_words_delete
199
+ self._words_delete_func.argtypes = [
200
+ POINTER(self.CWord)
201
+ ]
202
+ self._words_delete_func.restype = None
195
203
 
196
204
  Word = namedtuple('Word', ['word', 'start_sec', 'end_sec', 'confidence'])
197
205
 
@@ -221,6 +229,9 @@ class Leopard(object):
221
229
  if status is not self.PicovoiceStatuses.SUCCESS:
222
230
  raise self._PICOVOICE_STATUS_TO_EXCEPTION[status]()
223
231
 
232
+ transcript = c_transcript.value.decode('utf-8')
233
+ self._transcript_delete_func(c_transcript)
234
+
224
235
  words = list()
225
236
  for i in range(num_words.value):
226
237
  word = self.Word(
@@ -230,10 +241,9 @@ class Leopard(object):
230
241
  confidence=c_words[i].confidence)
231
242
  words.append(word)
232
243
 
233
- if num_words.value > 0:
234
- self._pv_free(c_words)
244
+ self._words_delete_func(c_words)
235
245
 
236
- return c_transcript.value.decode('utf-8'), words
246
+ return transcript, words
237
247
 
238
248
  def process_file(self, audio_path: str) -> Tuple[str, Sequence[Word]]:
239
249
  """
@@ -264,6 +274,9 @@ class Leopard(object):
264
274
  )
265
275
  raise self._PICOVOICE_STATUS_TO_EXCEPTION[status]()
266
276
 
277
+ transcript = c_transcript.value.decode('utf-8')
278
+ self._transcript_delete_func(c_transcript)
279
+
267
280
  words = list()
268
281
  for i in range(num_words.value):
269
282
  word = self.Word(
@@ -273,10 +286,9 @@ class Leopard(object):
273
286
  confidence=c_words[i].confidence)
274
287
  words.append(word)
275
288
 
276
- if num_words.value > 0:
277
- self._pv_free(c_words)
289
+ self._words_delete_func(c_words)
278
290
 
279
- return c_transcript.value.decode('utf-8'), words
291
+ return transcript, words
280
292
 
281
293
  def delete(self) -> None:
282
294
  """Releases resources acquired by Leopard."""
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2022 Picovoice Inc.
2
+ # Copyright 2022-2023 Picovoice Inc.
3
3
  #
4
4
  # You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE"
5
5
  # file accompanying this source.
Binary file
@@ -1,11 +1,13 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pvleopard
3
- Version: 1.1.4
3
+ Version: 1.2.0
4
4
  Summary: Leopard Speech-to-Text Engine.
5
5
  Home-page: https://github.com/Picovoice/leopard
6
6
  Author: Picovoice
7
7
  Author-email: hello@picovoice.ai
8
+ License: UNKNOWN
8
9
  Keywords: Speech-to-Text,Speech Recognition,Voice Recognition,ASR,Automatic Speech Recognition
10
+ Platform: UNKNOWN
9
11
  Classifier: Development Status :: 5 - Production/Stable
10
12
  Classifier: Intended Audience :: Developers
11
13
  Classifier: License :: OSI Approved :: Apache Software License
@@ -68,7 +70,24 @@ Replace `${ACCESS_KEY}` with yours obtained from [Picovoice Console](https://con
68
70
  `${AUDIO_PATH}` to the path an audio file. Finally, when done be sure to explicitly release the resources using
69
71
  `handle.delete()`.
70
72
 
73
+ ## Language Model
74
+
75
+ The Leopard Python SDK comes preloaded with a default English language model (`.pv` file).
76
+ Default models for other supported languages can be found in [lib/common](../../lib/common).
77
+
78
+ Create custom language models using the [Picovoice Console](https://console.picovoice.ai/). Here you can train
79
+ language models with custom vocabulary and boost words in the existing vocabulary.
80
+
81
+ Pass in the `.pv` file via the `model_path` argument:
82
+ ```python
83
+ handle = pvleopard.create(
84
+ access_key='${ACCESS_KEY}',
85
+ model_path='${MODEL_PATH}')
86
+ ```
87
+
71
88
  ## Demos
72
89
 
73
90
  [pvleoparddemo](https://pypi.org/project/pvleoparddemo/) provides command-line utilities for processing audio using
74
91
  Leopard.
92
+
93
+
@@ -0,0 +1,10 @@
1
+ pvleopard/LICENSE,sha256=ZurJwSSRHw99lGaJP88vQREqtZmIABuVKd_rK7k7U70,11344
2
+ pvleopard/__init__.py,sha256=OCI_7jgscvkzJMwT02SfB85_xOoQC8eb1e52HR_GKgo,577
3
+ pvleopard/_factory.py,sha256=WzrCwUlU_TCXkzZKPFd0ag4sAdiuwRlpOM6HYl1M-t0,1746
4
+ pvleopard/_leopard.py,sha256=qk9kf7aRETnbEyBOrZ7sg_ESgKm3NEow_6nnQjjl-ms,10366
5
+ pvleopard/_util.py,sha256=blfsGbVyqTjdHaj7RmU0DEc6fxab47w7EApDWCxKML8,3061
6
+ pvleopard/lib/common/leopard_params.pv,sha256=CBoaZ8kach9nVD-I-SJakBvbVi2EfxpiumH9Bk_DKCU,19850729
7
+ pvleopard-1.2.0.dist-info/METADATA,sha256=c_cUFkQUw7npZTyj9bSmob4XGpDx480NWYg_XcrWhCQ,3102
8
+ pvleopard-1.2.0.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
9
+ pvleopard-1.2.0.dist-info/top_level.txt,sha256=DAhlor-zWSROmsQCFWDsx_IJSE62zlgJ3sE4quxhEPw,10
10
+ pvleopard-1.2.0.dist-info/RECORD,,
Binary file
Binary file
@@ -1,18 +0,0 @@
1
- pvleopard/LICENSE,sha256=ZurJwSSRHw99lGaJP88vQREqtZmIABuVKd_rK7k7U70,11344
2
- pvleopard/__init__.py,sha256=9dNC_2TQ4YCYSkXthUBLgYy-7K8q_e4O5BHSrmw3j7c,1669
3
- pvleopard/leopard.py,sha256=pHsXWGHmk7RAQBccslZdoiVlb-p4NbAxuVqm1pLZzIE,9961
4
- pvleopard/util.py,sha256=vNvTOBiX5ZP9Gd_-vgd71EqPnY8YdPJ06muh2Smqhj0,3056
5
- pvleopard/lib/common/leopard_params.pv,sha256=kH9sOC_szGMkbHzSTRbmre-helqNFKXWmroAUK4FUcc,19139221
6
- pvleopard/lib/jetson/cortex-a57-aarch64/libpv_leopard.so,sha256=3JdoCvpp-d1Ih6cA9KE2kOQ1cAuNmJsRiX2Zm5thzEk,1274464
7
- pvleopard/lib/linux/x86_64/libpv_leopard.so,sha256=8FW1Ssktd9P7tgjbrkBmgAPG0zcUPaw4Q6wb3iLOzFE,1369208
8
- pvleopard/lib/mac/arm64/libpv_leopard.dylib,sha256=tnaN0GAIO3asFBJz6T1bCXxBVWesysY78jzNrSU9GKw,1496704
9
- pvleopard/lib/mac/x86_64/libpv_leopard.dylib,sha256=Tl7bDk89QjGKpvvbWIi0B-itAgjpZlu-Zf7BLFNmn7Y,1649744
10
- pvleopard/lib/raspberry-pi/cortex-a53/libpv_leopard.so,sha256=w066F-s2zMwRg-iBCFIAZegH0xBxvoYoS-vQ0YSJEXg,1234356
11
- pvleopard/lib/raspberry-pi/cortex-a53-aarch64/libpv_leopard.so,sha256=sCtOQMMO0Dvkyb_g3T9q6QU1e6uQViF33pOTLzTmx9k,1278648
12
- pvleopard/lib/raspberry-pi/cortex-a72/libpv_leopard.so,sha256=omvbYIrPa8dOUFe4Nnyr_AwcpQ2IwbHY7wltYGPWX8U,1246644
13
- pvleopard/lib/raspberry-pi/cortex-a72-aarch64/libpv_leopard.so,sha256=KgezrVHCLspnXPaBgle_qAbPO49mk-Z6pS_YldJo67Y,1266360
14
- pvleopard/lib/windows/amd64/libpv_leopard.dll,sha256=dWuDulgUuhJDWgTd8cJu_vCGK2CJLJES0JoRNKrrJog,1608192
15
- pvleopard-1.1.4.dist-info/METADATA,sha256=JpDaRWDQUK6rpJYQ8c93XQ9-fLEws_tk8-srn3VEk2A,2504
16
- pvleopard-1.1.4.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
17
- pvleopard-1.1.4.dist-info/top_level.txt,sha256=DAhlor-zWSROmsQCFWDsx_IJSE62zlgJ3sE4quxhEPw,10
18
- pvleopard-1.1.4.dist-info/RECORD,,