No project description provided
Project description
NeuralSpace VoiceAI Python Client
Installation
pip install voice-ai
Authentication
Set your NeuralSpace API Key to the environment variable NS_API_KEY
:
export NS_API_KEY=YOUR_API_KEY
Alternatively, you can also provide your API Key as a parameter when initializing VoiceAI
:
import neuralspace as ns
vai = ns.VoiceAI(api_key='YOUR_API_KEY')
Quickstart
import neuralspace as ns
vai = ns.VoiceAI()
# or,
# vai = ns.VoiceAI(api_key='YOUR_API_KEY')
# Setup job configuration
config = {
"file_transcription": {
"language_id": "en",
"mode": "advanced",
"number_formatting": "words",
},
}
# Create a new file transcription job
job_id = vai.transcribe(file='path/to/audio.wav', config=config)
print(job_id)
# Check the job's status
result = vai.get_job_status(job_id)
print(result)
More Features
Language Detection and Speaker Diarization
To enable language detection and speaker diarization, update the config as below:
config = {
"file_transcription": {
"language_id": "en",
"mode": "advanced",
"number_formatting": "words",
},
"language_detect": {},
"speaker_diarization": {},
}
Job Config
Instead of providing config as a dict
, you can provide it as a str
, pathlib.Path
or a file-like object.
job_id = vai.transcribe(
file='path/to/audio.wav',
config='{"file_transcription": {"language_id": "en", "mode": "advanced", "number_formatting": "words"}}',
)
# or,
job_id = vai.transcribe(
file='path/to/audio.wav',
config='path/to/config.json',
)
# or,
with open('path/to/config.json') as fp:
job_id = vai.transcribe(
file='path/to/audio.wav',
config=fp
)
Wait for completion
You can also poll for the status and wait until the job completes:
result = vai.poll_until_complete(job_id)
print(result.data.result.transcription.transcript)
Note: This will block the calling thread until the job is complete.
Callbacks
You can also provide a callback function when creating the job.
It will be called with the result once the job completes.
def callback(result):
print(f'job completed: {result.data.jobId}')
print(result.data.result.transcription.transcript)
job_id = vai.transcribe(file='path/to/audio.wav', config=config, on_complete=callback)
Note: transcribe()
will return the job_id
as soon as the job is scheduled, and the provided callback will be called on a new thread.
The calling thread will not be blocked in this case.
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 voice-ai-0.0.1.tar.gz
.
File metadata
- Download URL: voice-ai-0.0.1.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6aad5b5cb0d19a6f76e54a7a573ec9d2b65392775d4ac75c81938707677dfb5 |
|
MD5 | d3969fb4a9a0b698c55d7f38c7d62e56 |
|
BLAKE2b-256 | b446b6bedd53dd51c3a9159a0ee60e3d799aaf386e53968d51b37648f6152f15 |
File details
Details for the file voice_ai-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: voice_ai-0.0.1-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06fc9f9525ea6b2b6abe9f0245201366851fed4d52473be666f31c1e26672216 |
|
MD5 | 375d3b226e98df474441608c7a136458 |
|
BLAKE2b-256 | dc798091c93e0b55546bbc2e8efa274aad98047d93a2bd271b9ec3cb40200a7b |