abaxai-speech-client-0.1.1
توضیحات
A Python3 client to connect and use Abax.AI Speech services
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | abaxai-speech-client-0.1.1 |
| نام | abaxai-speech-client |
| نسخه کتابخانه | 0.1.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | AbaxAI Developer |
| ایمیل نویسنده | tlvu@ntu.edu.sg |
| آدرس صفحه اصلی | https://github.com/ntuspeechlab/asr-client-scripts |
| آدرس اینترنتی | https://pypi.org/project/abaxai-speech-client/ |
| مجوز | - |
## Project description
This is the speech client python package built by Abax.AI
It allows use to use speech to text services in both manners: offline and online
Online streaming will take audio stream in realtime, and return the transcripts on the fly
Offline transcribing will read your audio file, transcribe and return the transcripts in different formats.
## Examples
### Stream your audio file with python3
import io
from abaxai_sdk import streaming
accessToken = 'YOUR_ACCESS_TOKEN'
def get_wav_data(wavfile):
for block in iter(lambda: wavfile.read(1280), b""):
yield generate_block(block)
def generate_block(block):
return block
def abaxai_streaming(stream_file):
"""Streams transcription of the given audio file."""
client = streaming.SpeechClient()
config = streaming.RecognitionConfig(
encoding=streaming.AudioEncoding.LINEAR16,
sample_rate_hertz=16000,
language_code="en-US",
model="basic_english",
)
streaming_config = streaming.StreamingRecognitionConfig(config, accessToken)
# In practice, stream should be a generator yielding chunks of audio data.
with io.open(stream_file, 'rb') as audiostream:
data = get_wav_data(audiostream)
requests = (
streaming.StreamingRecognizeRequest(audio_content=chunk) for chunk in data
)
responses = client.streaming_recognize(
config=streaming_config,
requests=requests,
)
print("\n\nFinal transcripts: \n")
for response in responses:
print(response)
audio_file = "your_audio_file.wav"
print("Streaming the audio file")
abaxai_streaming(audio_file)
### Transcribe your audio file with python3
from abaxai_sdk import transcribing
accessToken = 'YOUR_ACCESS_TOKEN'
def abaxai_transcribe(audio_filepath):
"""Streams transcription of the given audio file."""
client = transcribing.SpeechClient()
config = transcribing.RecognitionConfig(
encoding=transcribing.AudioEncoding.LINEAR16,
sample_rate_hertz=16000,
language_code="en-US",
model="wenet-english",
)
transcribing_config = transcribing.TranscribeConfig(config, accessToken)
client.recognize(config=transcribing_config,
audiofilepath=audio_filepath,)
# speechid = "<your_speech_id>"
# client.get_transcription(speechid, accessToken)
print("Done.")
audio_file = "your_audio_file.wav"
print("Transcribe the audio file")
abaxai_transcribe(audio_file)
## Resources
Homepage: https://abax.ai/
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.6 | Python |
نحوه نصب
نصب پکیج whl abaxai-speech-client-0.1.1:
pip install abaxai-speech-client-0.1.1.whl
نصب پکیج tar.gz abaxai-speech-client-0.1.1:
pip install abaxai-speech-client-0.1.1.tar.gz