A Python3 client to connect and use Abax.AI Speech services
Project description
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/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file abaxai-speech-client-0.1.2.tar.gz
.
File metadata
- Download URL: abaxai-speech-client-0.1.2.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 301639cfad0e6490fa89362da7c367ec42343018f949851ceb50473fa6459dc1 |
|
MD5 | 02e5dc6aa188aae268cd6b1b01a7d29a |
|
BLAKE2b-256 | 1dd9a252ce326831c55f5536ee601933125c64f1200d4536a41a9f84c551fc3e |
File details
Details for the file abaxai_speech_client-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: abaxai_speech_client-0.1.2-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c1acff1d411c1a07d199f9c7f2917d1953c0a6dfeeaeeff3573a4e37e9e15fc |
|
MD5 | d6649005bc5662f29852a5048ac3f938 |
|
BLAKE2b-256 | 423e82436bae3df2a7f5ab5fc42e81d4f1f535cd6733c5dab53b290aae6dc01b |