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/
Metadata
Release files for abaxai-speech-client 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| abaxai-speech-client-0.1.2.tar.gz | 9.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| abaxai_speech_client-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.6 kB
Release files / abaxai-speech-client-0.1.2.tar.gz
| Download URL | abaxai-speech-client-0.1.2.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
301639cfad0e6490fa89362da7c367ec42343018f949851ceb50473fa6459dc1
|
|
BLAKE2b-256 checksum How to use checksums |
1dd9a252ce326831c55f5536ee601933125c64f1200d4536a41a9f84c551fc3e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|
Release files / abaxai_speech_client-0.1.2-py3-none-any.whl
| Download URL | abaxai_speech_client-0.1.2-py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9c1acff1d411c1a07d199f9c7f2917d1953c0a6dfeeaeeff3573a4e37e9e15fc
|
|
BLAKE2b-256 checksum How to use checksums |
423e82436bae3df2a7f5ab5fc42e81d4f1f535cd6733c5dab53b290aae6dc01b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|