ailia-speech 1.3.0.5__py3-none-any.whl → 1.3.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ailia-speech might be problematic. Click here for more details.

ailia_speech/__init__.py CHANGED
@@ -67,6 +67,7 @@ AILIA_SPEECH_MODEL_TYPE_WHISPER_MULTILINGUAL_SMALL = (2)
67
67
  AILIA_SPEECH_MODEL_TYPE_WHISPER_MULTILINGUAL_MEDIUM = (3)
68
68
  AILIA_SPEECH_MODEL_TYPE_WHISPER_MULTILINGUAL_LARGE = (4)
69
69
  AILIA_SPEECH_MODEL_TYPE_WHISPER_MULTILINGUAL_LARGE_V3 = (5)
70
+ AILIA_SPEECH_MODEL_TYPE_WHISPER_MULTILINGUAL_LARGE_V3_TURBO = (6)
70
71
 
71
72
  AILIA_SPEECH_TASK_TRANSCRIBE = (0)
72
73
  AILIA_SPEECH_TASK_TRANSLATE = (1)
@@ -260,6 +261,9 @@ dll.ailiaSpeechSetIntermediateCallback.argtypes = (c_void_p, AILIA_SPEECH_USER_A
260
261
  dll.ailiaSpeechSetLanguage.restype = c_int
261
262
  dll.ailiaSpeechSetLanguage.argtypes = (c_void_p, c_char_p)
262
263
 
264
+ dll.ailiaSpeechSetSilentThreshold.restype = c_int
265
+ dll.ailiaSpeechSetSilentThreshold.argtypes = (c_void_p, c_float, c_float, c_float)
266
+
263
267
  # ==============================================================================
264
268
  # model download
265
269
  # ==============================================================================
@@ -425,6 +429,12 @@ class Whisper(AiliaSpeechModel):
425
429
  decoder_path = "decoder_large_v3_fix_kv_cache.onnx"
426
430
  encoder_pb_path = "encoder_large_v3_weights.pb"
427
431
  decoder_pb_path = "decoder_large_v3_fix_kv_cache_weights.pb"
432
+ elif model_type == AILIA_SPEECH_MODEL_TYPE_WHISPER_MULTILINGUAL_LARGE_V3_TURBO:
433
+ encoder_path = "encoder_turbo.onnx"
434
+ decoder_path = "decoder_turbo_fix_kv_cache.onnx"
435
+ encoder_pb_path = "encoder_turbo_weights.pb"
436
+ decoder_pb_path = None
437
+ model_type = AILIA_SPEECH_MODEL_TYPE_WHISPER_MULTILINGUAL_LARGE_V3
428
438
  self._download_model(model_path, encoder_path, decoder_path, encoder_pb_path, decoder_pb_path)
429
439
  self._open_model(model_path + encoder_path, model_path + decoder_path, model_type)
430
440
  self._open_vad(model_path + "silero_vad.onnx", AILIA_SPEECH_VAD_TYPE_SILERO)
@@ -459,6 +469,9 @@ class Whisper(AiliaSpeechModel):
459
469
  else:
460
470
  self._check(dll.ailiaSpeechOpenVadFileA(self._instance, p1, vad_type))
461
471
 
472
+ def set_silent_threshold(self, silent_threshold, speech_sec, no_speech_sec):
473
+ self._check(dll.ailiaSpeechSetSilentThreshold(self._instance, silent_threshold, speech_sec, no_speech_sec))
474
+
462
475
  def transcribe(self, audio_waveform, sampling_rate, lang = None):
463
476
  if len(audio_waveform.shape) == 1:
464
477
  channels = 1
@@ -494,6 +507,43 @@ class Whisper(AiliaSpeechModel):
494
507
 
495
508
  self._check(dll.ailiaSpeechResetTranscribeState(self._instance))
496
509
 
510
+ def transcribe_step(self, audio_waveform, sampling_rate, complete, lang = None):
511
+ if len(audio_waveform.shape) == 1:
512
+ channels = 1
513
+ elif len(audio_waveform.shape) == 2:
514
+ channels = audio_waveform.shape[0]
515
+ audio_waveform = numpy.transpose(audio_waveform, (1, 0)).flatten()
516
+ else:
517
+ raise AiliaSpeechError(f"audio_waveform must be 1 channel or 2 channel", -1)
518
+
519
+ audio_waveform = numpy.ascontiguousarray(audio_waveform.astype(numpy.float32))
520
+
521
+ if lang is not None:
522
+ self._check(dll.ailiaSpeechSetLanguage(self._instance, self._string_buffer(lang)))
523
+
524
+ self._check(dll.ailiaSpeechPushInputData(self._instance, audio_waveform, channels, audio_waveform.shape[0] // channels, sampling_rate))
525
+ if complete:
526
+ self._check(dll.ailiaSpeechFinalizeInputData(self._instance))
527
+
528
+ while True:
529
+ buffered = ctypes.c_uint(0)
530
+ self._check(dll.ailiaSpeechBuffered(self._instance, ctypes.byref(buffered)))
531
+ if buffered.value == 0:
532
+ break
533
+
534
+ self._check(dll.ailiaSpeechTranscribe(self._instance))
535
+
536
+ count = ctypes.c_uint(0)
537
+ self._check(dll.ailiaSpeechGetTextCount(self._instance, ctypes.byref(count)))
538
+ results = []
539
+ for i in range(count.value):
540
+ text = AILIASpeechText()
541
+ self._check(dll.ailiaSpeechGetText(self._instance, ctypes.byref(text), AILIA_SPEECH_TEXT_VERSION, i))
542
+ yield {"text" : text.text.decode(), "time_stamp_begin" : text.time_stamp_begin, "time_stamp_end" : text.time_stamp_end, "person_id" : text.person_id, "language" : text.language.decode(), "confidence" : text.confidence}
543
+
544
+ if complete:
545
+ self._check(dll.ailiaSpeechResetTranscribeState(self._instance))
546
+
497
547
  def __del__(self):
498
548
  if self._instance:
499
549
  dll.ailiaSpeechDestroy(cast(self._instance, c_void_p))
@@ -67,6 +67,7 @@ AILIA_SPEECH_MODEL_TYPE_WHISPER_MULTILINGUAL_SMALL = (2)
67
67
  AILIA_SPEECH_MODEL_TYPE_WHISPER_MULTILINGUAL_MEDIUM = (3)
68
68
  AILIA_SPEECH_MODEL_TYPE_WHISPER_MULTILINGUAL_LARGE = (4)
69
69
  AILIA_SPEECH_MODEL_TYPE_WHISPER_MULTILINGUAL_LARGE_V3 = (5)
70
+ AILIA_SPEECH_MODEL_TYPE_WHISPER_MULTILINGUAL_LARGE_V3_TURBO = (6)
70
71
 
71
72
  AILIA_SPEECH_TASK_TRANSCRIBE = (0)
72
73
  AILIA_SPEECH_TASK_TRANSLATE = (1)
@@ -260,6 +261,9 @@ dll.ailiaSpeechSetIntermediateCallback.argtypes = (c_void_p, AILIA_SPEECH_USER_A
260
261
  dll.ailiaSpeechSetLanguage.restype = c_int
261
262
  dll.ailiaSpeechSetLanguage.argtypes = (c_void_p, c_char_p)
262
263
 
264
+ dll.ailiaSpeechSetSilentThreshold.restype = c_int
265
+ dll.ailiaSpeechSetSilentThreshold.argtypes = (c_void_p, c_float, c_float, c_float)
266
+
263
267
  # ==============================================================================
264
268
  # model download
265
269
  # ==============================================================================
@@ -425,6 +429,12 @@ class Whisper(AiliaSpeechModel):
425
429
  decoder_path = "decoder_large_v3_fix_kv_cache.onnx"
426
430
  encoder_pb_path = "encoder_large_v3_weights.pb"
427
431
  decoder_pb_path = "decoder_large_v3_fix_kv_cache_weights.pb"
432
+ elif model_type == AILIA_SPEECH_MODEL_TYPE_WHISPER_MULTILINGUAL_LARGE_V3_TURBO:
433
+ encoder_path = "encoder_turbo.onnx"
434
+ decoder_path = "decoder_turbo_fix_kv_cache.onnx"
435
+ encoder_pb_path = "encoder_turbo_weights.pb"
436
+ decoder_pb_path = None
437
+ model_type = AILIA_SPEECH_MODEL_TYPE_WHISPER_MULTILINGUAL_LARGE_V3
428
438
  self._download_model(model_path, encoder_path, decoder_path, encoder_pb_path, decoder_pb_path)
429
439
  self._open_model(model_path + encoder_path, model_path + decoder_path, model_type)
430
440
  self._open_vad(model_path + "silero_vad.onnx", AILIA_SPEECH_VAD_TYPE_SILERO)
@@ -459,6 +469,9 @@ class Whisper(AiliaSpeechModel):
459
469
  else:
460
470
  self._check(dll.ailiaSpeechOpenVadFileA(self._instance, p1, vad_type))
461
471
 
472
+ def set_silent_threshold(self, silent_threshold, speech_sec, no_speech_sec):
473
+ self._check(dll.ailiaSpeechSetSilentThreshold(self._instance, silent_threshold, speech_sec, no_speech_sec))
474
+
462
475
  def transcribe(self, audio_waveform, sampling_rate, lang = None):
463
476
  if len(audio_waveform.shape) == 1:
464
477
  channels = 1
@@ -494,6 +507,43 @@ class Whisper(AiliaSpeechModel):
494
507
 
495
508
  self._check(dll.ailiaSpeechResetTranscribeState(self._instance))
496
509
 
510
+ def transcribe_step(self, audio_waveform, sampling_rate, complete, lang = None):
511
+ if len(audio_waveform.shape) == 1:
512
+ channels = 1
513
+ elif len(audio_waveform.shape) == 2:
514
+ channels = audio_waveform.shape[0]
515
+ audio_waveform = numpy.transpose(audio_waveform, (1, 0)).flatten()
516
+ else:
517
+ raise AiliaSpeechError(f"audio_waveform must be 1 channel or 2 channel", -1)
518
+
519
+ audio_waveform = numpy.ascontiguousarray(audio_waveform.astype(numpy.float32))
520
+
521
+ if lang is not None:
522
+ self._check(dll.ailiaSpeechSetLanguage(self._instance, self._string_buffer(lang)))
523
+
524
+ self._check(dll.ailiaSpeechPushInputData(self._instance, audio_waveform, channels, audio_waveform.shape[0] // channels, sampling_rate))
525
+ if complete:
526
+ self._check(dll.ailiaSpeechFinalizeInputData(self._instance))
527
+
528
+ while True:
529
+ buffered = ctypes.c_uint(0)
530
+ self._check(dll.ailiaSpeechBuffered(self._instance, ctypes.byref(buffered)))
531
+ if buffered.value == 0:
532
+ break
533
+
534
+ self._check(dll.ailiaSpeechTranscribe(self._instance))
535
+
536
+ count = ctypes.c_uint(0)
537
+ self._check(dll.ailiaSpeechGetTextCount(self._instance, ctypes.byref(count)))
538
+ results = []
539
+ for i in range(count.value):
540
+ text = AILIASpeechText()
541
+ self._check(dll.ailiaSpeechGetText(self._instance, ctypes.byref(text), AILIA_SPEECH_TEXT_VERSION, i))
542
+ yield {"text" : text.text.decode(), "time_stamp_begin" : text.time_stamp_begin, "time_stamp_end" : text.time_stamp_end, "person_id" : text.person_id, "language" : text.language.decode(), "confidence" : text.confidence}
543
+
544
+ if complete:
545
+ self._check(dll.ailiaSpeechResetTranscribeState(self._instance))
546
+
497
547
  def __del__(self):
498
548
  if self._instance:
499
549
  dll.ailiaSpeechDestroy(cast(self._instance, c_void_p))
@@ -0,0 +1,123 @@
1
+ Metadata-Version: 2.1
2
+ Name: ailia_speech
3
+ Version: 1.3.1.1
4
+ Summary: ailia AI Speech
5
+ Home-page: https://ailia.jp/
6
+ Author: ax Inc.
7
+ Author-email: contact@axinc.jp
8
+ License: https://ailia.ai/en/license/
9
+ Requires-Python: >3.6
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: ailia
12
+ Requires-Dist: ailia-tokenizer
13
+
14
+ # ailia AI Speech Python API
15
+
16
+ !! CAUTION !!
17
+ “ailia” IS NOT OPEN SOURCE SOFTWARE (OSS).
18
+ As long as user complies with the conditions stated in [License Document](https://ailia.ai/license/), user may use the Software for free of charge, but the Software is basically paid software.
19
+
20
+ ## About ailia AI Speech
21
+
22
+ ailia AI Speech is a library to perform speech recognition using AI. It provides a C API for native applications, as well as a C# API well suited for Unity applications. Using ailia AI Speech, you can easily integrate AI powered speech recognition into your applications.
23
+
24
+ ## Install from pip
25
+
26
+ You can install the ailia AI Speech free evaluation package with the following command.
27
+
28
+ ```
29
+ pip3 install ailia_speech
30
+ ```
31
+
32
+ ## Install from package
33
+
34
+ You can install the ailia AI Speech from Package with the following command.
35
+
36
+ ```
37
+ python3 bootstrap.py
38
+ pip3 install ./
39
+ ```
40
+
41
+ ## Usage
42
+
43
+ ### Batch mode
44
+
45
+ In batch mode, the entire audio is transcribed at once.
46
+
47
+ ```python
48
+ import ailia_speech
49
+
50
+ import librosa
51
+
52
+ import os
53
+ import urllib.request
54
+
55
+ # Load target audio
56
+ input_file_path = "demo.wav"
57
+ if not os.path.exists(input_file_path):
58
+ urllib.request.urlretrieve(
59
+ "https://github.com/axinc-ai/ailia-models/raw/refs/heads/master/audio_processing/whisper/demo.wa",
60
+ "demo.wav"
61
+ )
62
+ audio_waveform, sampling_rate = librosa.load(input_file_path, mono = True)
63
+
64
+ # Infer
65
+ speech = ailia_speech.Whisper()
66
+ speech.initialize_model(model_path = "./models/", model_type = ailia_speech.AILIA_SPEECH_MODEL_TYPE_WHISPER_MULTILINGUAL_LARGE_V3_TURBO)
67
+ recognized_text = speech.transcribe(audio_waveform, sampling_rate)
68
+ for text in recognized_text:
69
+ print(text)
70
+ ```
71
+
72
+ ### Step mode
73
+
74
+ In step mode, the audio is input in chunks and transcribed sequentially.
75
+
76
+ ```python
77
+ import ailia_speech
78
+
79
+ import librosa
80
+
81
+ import os
82
+ import urllib.request
83
+
84
+ # Load target audio
85
+ input_file_path = "demo.wav"
86
+ if not os.path.exists(input_file_path):
87
+ urllib.request.urlretrieve(
88
+ "https://github.com/axinc-ai/ailia-models/raw/refs/heads/master/audio_processing/whisper/demo.wa",
89
+ "demo.wav"
90
+ )
91
+ audio_waveform, sampling_rate = librosa.load(input_file_path, mono = True)
92
+
93
+ # Infer
94
+ speech = ailia_speech.Whisper()
95
+ speech.initialize_model(model_path = "./models/", model_type = ailia_speech.AILIA_SPEECH_MODEL_TYPE_WHISPER_MULTILINGUAL_LARGE_V3_TURBO)
96
+ speech.set_silent_threshold(silent_threshold = 0.5, speech_sec = 1.0, no_speech_sec = 0.5)
97
+ for i in range(0, audio_waveform.shape[0], sampling_rate):
98
+ complete = False
99
+ if i + sampling_rate >= audio_waveform.shape[0]:
100
+ complete = True
101
+ recognized_text = speech.transcribe_step(audio_waveform[i:min(audio_waveform.shape[0], i + sampling_rate)], sampling_rate, complete)
102
+ for text in recognized_text:
103
+ print(text)
104
+ ```
105
+
106
+ ### Available model types
107
+
108
+ It is possible to select multiple models according to accuracy and speed. LARGE_V3_TURBO is the most recommended.
109
+
110
+ ```
111
+ ailia_speech.AILIA_SPEECH_MODEL_TYPE_WHISPER_MULTILINGUAL_TINY
112
+ ilia_speech.AILIA_SPEECH_MODEL_TYPE_WHISPER_MULTILINGUAL_BASE
113
+ ailia_speech.AILIA_SPEECH_MODEL_TYPE_WHISPER_MULTILINGUAL_SMALL
114
+ ailia_speech.AILIA_SPEECH_MODEL_TYPE_WHISPER_MULTILINGUAL_MEDIUM
115
+ ailia_speech.AILIA_SPEECH_MODEL_TYPE_WHISPER_MULTILINGUAL_LARGE
116
+ ailia_speech.AILIA_SPEECH_MODEL_TYPE_WHISPER_MULTILINGUAL_LARGE_V3
117
+ ailia_speech.AILIA_SPEECH_MODEL_TYPE_WHISPER_MULTILINGUAL_LARGE_V3_TURBO
118
+ ```
119
+
120
+ ## API specification
121
+
122
+ https://github.com/axinc-ai/ailia-sdk
123
+
@@ -1,12 +1,12 @@
1
1
  ailia_speech/LICENSE_AILIA_EN.pdf,sha256=1DzVViPnw1uAS8gJ5a8uN3iZNNR5I1ItIXmezHfUpeM,70149
2
2
  ailia_speech/LICENSE_AILIA_JA.pdf,sha256=s628QN47S2bNqIfuSjm2LBf0vIluv2df6MSemn6Ksmw,174134
3
- ailia_speech/__init__.py,sha256=owi3WkmDlaYf0P1TJF_CVyVSW-cLMj3kp9RoVH9Rd3c,25637
3
+ ailia_speech/__init__.py,sha256=xPkxrpftgloJIsJtnAYvrn7TYemZDmnQRQFBY2sw_AM,28247
4
4
  ailia_speech/linux/arm64-v8a/libailia_speech.so,sha256=JAOwnBr7lbiMZmPCM99pd4vJQ08ZuXDPpq-FurrXSnE,166096
5
5
  ailia_speech/linux/x64/libailia_speech.so,sha256=WbFvA5wKTgS_Zx8ErT7WBKJbzOUexavr4nP4EkLNawQ,171360
6
6
  ailia_speech/mac/libailia_speech.dylib,sha256=-JAC40yLslAVMvfh6LhDvP3Zyt3hIT3WZc7wa9-07zU,317112
7
7
  ailia_speech/windows/x64/ailia_speech.dll,sha256=WJCOHi0Na4tdMG1RT7dA7yAoWumiGSWeW1vxUtiXDS8,126464
8
- ailia_speech-1.3.0.5.data/scripts/__init__.py,sha256=owi3WkmDlaYf0P1TJF_CVyVSW-cLMj3kp9RoVH9Rd3c,25637
9
- ailia_speech-1.3.0.5.dist-info/METADATA,sha256=webGrA8CrUKo8WSk_vIvqb_aDekuX7yzXlelkeOrP6M,1932
10
- ailia_speech-1.3.0.5.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
11
- ailia_speech-1.3.0.5.dist-info/top_level.txt,sha256=Ou9XeJ9AvdK8eutw07oosCthftD1tRYzAgNY2BrYhDc,13
12
- ailia_speech-1.3.0.5.dist-info/RECORD,,
8
+ ailia_speech-1.3.1.1.data/scripts/__init__.py,sha256=xPkxrpftgloJIsJtnAYvrn7TYemZDmnQRQFBY2sw_AM,28247
9
+ ailia_speech-1.3.1.1.dist-info/METADATA,sha256=94CtHDDVDFXGtdgoVERZmuSb1ugljsVAR7VK6t9tL7o,3701
10
+ ailia_speech-1.3.1.1.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
11
+ ailia_speech-1.3.1.1.dist-info/top_level.txt,sha256=Ou9XeJ9AvdK8eutw07oosCthftD1tRYzAgNY2BrYhDc,13
12
+ ailia_speech-1.3.1.1.dist-info/RECORD,,
@@ -1,71 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: ailia_speech
3
- Version: 1.3.0.5
4
- Summary: ailia AI Speech
5
- Home-page: https://ailia.jp/
6
- Author: ax Inc.
7
- Author-email: contact@axinc.jp
8
- License: https://ailia.ai/en/license/
9
- Requires-Python: >3.6
10
- Description-Content-Type: text/markdown
11
- Requires-Dist: ailia
12
- Requires-Dist: ailia-tokenizer
13
-
14
- # ailia AI Speech Python API
15
-
16
- !! CAUTION !!
17
- “ailia” IS NOT OPEN SOURCE SOFTWARE (OSS).
18
- As long as user complies with the conditions stated in [License Document](https://ailia.ai/license/), user may use the Software for free of charge, but the Software is basically paid software.
19
-
20
- ## About ailia AI Speech
21
-
22
- ailia AI Speech is a library to perform speech recognition using AI. It provides a C API for native applications, as well as a C# API well suited for Unity applications. Using ailia AI Speech, you can easily integrate AI powered speech recognition into your applications.
23
-
24
- ## Install from pip
25
-
26
- You can install the ailia AI Speech free evaluation package with the following command.
27
-
28
- ```
29
- pip3 install ailia_speech
30
- ```
31
-
32
- ## Install from package
33
-
34
- You can install the ailia AI Speech from Package with the following command.
35
-
36
- ```
37
- python3 bootstrap.py
38
- pip3 install ./
39
- ```
40
-
41
- ## Usage
42
-
43
- ```python
44
- import ailia_speech
45
-
46
- import librosa
47
-
48
- import os
49
- import urllib.request
50
-
51
- # Load target audio
52
- input_file_path = "demo.wav"
53
- if not os.path.exists(input_file_path):
54
- urllib.request.urlretrieve(
55
- "https://github.com/axinc-ai/ailia-models/raw/refs/heads/master/audio_processing/whisper/demo.wa",
56
- "demo.wav"
57
- )
58
- audio_waveform, sampling_rate = librosa.load(input_file_path, mono=True)
59
-
60
- # Infer
61
- speech = ailia_speech.Whisper()
62
- speech.initialize_model(model_path = "./models/", model_type = ailia_speech.AILIA_SPEECH_MODEL_TYPE_WHISPER_MULTILINGUAL_SMALL)
63
- recognized_text = speech.transcribe(audio_waveform, sampling_rate)
64
- for text in recognized_text:
65
- print(text)
66
- ```
67
-
68
- ## API specification
69
-
70
- https://github.com/axinc-ai/ailia-sdk
71
-