Example
File Transcription Job with all Features Enabled
- API
- Python SDK
Request
curl --location 'https://voice.neuralspace.ai/api/v2/jobs' \
--header 'Authorization: sk_77cc9eca324de4093b25c9edffab5510e...' \
--form 'files=@"3W6XbU8Ti/english_audio_sample.mp3"' \
--form 'config="{\"file_transcription\": {\"language_id\": \"en\", \"mode\": \"fast\", \"number_formatting\": \"words\"}, \"speaker_diarization\": {}, \"translation\": {\"source_language\": \"en\", \"target_languages\": [\"hi\", \"ar\"]}, \"summarize\": true, \"sentiment_detect\": true, \"dictionary\": {\"words\": [\"ZyntriQix\"]}}, \"subtitles_guidelines\": { \"line_count\": 2, \"duration\": 5, \"character_count\": 32 }"''
Response
{
"success": true,
"message": "Job created successfully",
"data": {
"jobId": "6abe4f35-8220-4981-95c7-3b040d9b86d1"
}
}
Script
import requests
import neuralspace as ns
filename = 'english_audio_sample.mp3'
# Download the sample audio file
print('Downloading sample audio file...')
resp = requests.get('https://github.com/Neural-Space/neuralspace-examples/raw/main/datasets/transcription/en/english_audio_sample.mp3')
with open(filename, 'wb') as fp:
fp.write(resp.content)
vai = ns.VoiceAI()
# or,
# vai = ns.VoiceAI(api_key='YOUR_API_KEY')
# Setup job configuration
config = {
"file_transcription": {
"language_id": "en",
"mode": "fast",
"number_formatting": "words"
},
"translation": {
"source_language": "en",
"target_languages": [
"hi",
"ar"
]
},
"summarize": True,
"sentiment_detect": True,
"subtitles_guidelines": {
"line_count": 2,
"duration": 5,
"character_count": 32
},
"speaker_diarization": {},
"dictionary": {
"words": [
"ZyntriQix"
]
}
}
# Create a new file transcription job
job_id = vai.transcribe(file=filename, config=config)
# print(f'Created job: {job_id}')
# Check the job's status
result = vai.get_job_status(job_id)
# print(f'Current status:\n{result}')
# This should finish in a minute for the sample audio used here.
# It will depend on the duration of the audio file and other config options.
result = vai.poll_until_complete(job_id)
print(result)
File Transcription Full Result
- API
- Python SDK
Request
curl --location 'voice.neuralspace.ai/api/v2/jobs/6abe4f35-8220-4981-95c7-3b040d9b86d1' \
--header 'Authorization: sk_ccc189928681a411e7a538201bc650c50167eb2363...'
Script
The script mentioned above will also return results directly, but in case you want to use job_id
to fetch results, the below script can help you do exactly that.
import requests
import neuralspace as ns
vai = ns.VoiceAI()
# or,
# vai = ns.VoiceAI(api_key='YOUR_API_KEY')
# Assign your job's ID to a variable
job_id = "5de7f2e0-0f67-416e-809e-85ed9de1641e"
# Fetch a completed job's result
result = vai.get_job_status(job_id)
print(result)
Response
{
"success": true,
"message": "Data fetched successfully",
"data": {
"timestamp": 1705310202265,
"filename": "english_audio_sample.mp3",
"jobId": "5de7f2e0-0f67-416e-809e-85ed9de1641e",
"params": {
"file_transcription": {
"language_id": "en",
"mode": "fast",
"number_formatting": "words"
},
"translation": {
"source_language": "en",
"target_languages": [
"hi",
"ar"
]
},
"summarize": true,
"sentiment_detect": true,
"subtitles_guidelines": {
"line_count": 2,
"duration": 5,
"character_count": 32
},
"dictionary": {
"words": [
"ZyntriQix"
]
}
},
"status": "Completed",
"audioDuration": 131.568,
"messsage": "",
"progress": [
"Queued",
"Started",
"Transcription Started",
"Speaker Diarization Started",
"Speaker Diarization Completed",
"Transcription Completed",
"Subtitles Started",
"Subtitles Completed",
"Sentiment Detection Started",
"Summarization Started",
"Translation Started",
"Translation Completed",
"Summarization Completed",
"Sentiment Detection Completed",
"Completed"
],
"result": {
"transcription": {
"channels": {
"0": {
"transcript": "We've been at this for hours now. Have you found anything useful in any of those books? Not a single thing Lewis. I'm sure that there must be something in this library...",
"enhanced_transcript": null,
"timestamps": [
{
"word": "We've",
"start": 6.65,
"end": 6.99,
"conf": 0.82
},
{
"word": "been",
"start": 6.99,
"end": 7.09,
"conf": 0.99
},
{
"word": "at",
"start": 7.09,
"end": 7.21,
"conf": 0.99
},
{
"word": "this",
"start": 7.21,
"end": 7.39,
"conf": 0.98
},
{
"word": "for",
"start": 7.39,
"end": 7.45,
"conf": 0.93
},
{
"word": "hours",
"start": 7.45,
"end": 7.87,
"conf": 0.96
},
{
"word": "now.",
"start": 7.87,
"end": 8.41,
"conf": 0.97
},
{
"word": "Have",
"start": 8.41,
"end": 8.49,
"conf": 0.99
},
{
"word": "you",
"start": 8.49,
"end": 8.65,
"conf": 0.99
},
{
"word": "found",
"start": 8.65,
"end": 8.83,
"conf": 0.96
}
]
}
},
"segments": [
{
"startTime": 6.741562500000001,
"endTime": 8.41,
"text": "We've been at this for hours\nnow.",
"speaker": "Speaker 1",
"channel": 0,
"sentiment": "neutral"
},
{
"startTime": 8.41,
"endTime": 10.200937500000002,
"text": "Have you found anything useful\nin any of those books?",
"speaker": "Speaker 1",
"channel": 0,
"sentiment": "neutral"
},
{
"startTime": 10.740937500000001,
"endTime": 13.27,
"text": "Not a single thing Lewis.\nI'm sure that there must be",
"speaker": "Speaker 0",
"channel": 0,
"sentiment": "negative"
},
{
"startTime": 13.27,
"endTime": 15.67,
"text": "something in this library.\nIt's not like there's nothing",
"speaker": "Speaker 0",
"channel": 0,
"sentiment": "neutral"
}
],
"summary": "Summary: The speakers have been searching for something in a library for hours. They take a break and hear a noise coming from the back of the library..."
},
"translation": {
"hi": {
"channels": {
"0": "हम इस पर घंटों से हैं\nअब। क्या आपको कुछ उपयोगी मिला?\nउन किताबों में से किसी में? एक भी चीज़ नहीं लुईस.\nमुझे यकीन है कि होना ही चाहिए इस पुस्तकालय में कुछ..."
},
"segments": [
{
"startTime": 6.741562500000001,
"endTime": 8.41,
"text": "हम इस पर घंटों से हैं\nअब।",
"speaker": "Speaker 1",
"channel": 0
},
{
"startTime": 8.41,
"endTime": 10.200937500000002,
"text": "क्या आपको कुछ उपयोगी मिला?\nउन किताबों में से किसी में?",
"speaker": "Speaker 1",
"channel": 0
},
{
"startTime": 10.740937500000001,
"endTime": 13.27,
"text": "एक भी चीज़ नहीं लुईस.\nमुझे यकीन है कि होना ही चाहिए",
"speaker": "Speaker 0",
"channel": 0
},
{
"startTime": 13.27,
"endTime": 15.67,
"text": "इस पुस्तकालय में कुछ.\nऐसा नहीं है कि कुछ भी नहीं है",
"speaker": "Speaker 0",
"channel": 0
}
],
"summary": "सारांश: वक्ता घंटों से लाइब्रेरी में कुछ खोज रहे हैं। वे विश्राम करते हैं और पुस्तकालय के पीछे से एक शोर सुनते हैं।.."
},
"ar": {
"channels": {
"0": "لقد كنا في هذا لساعات\nالآن. هل وجدت أي شيء مفيد\nفي أي من تلك الكتب؟ لا شيء واحد لويس..."
},
"segments": [
{
"startTime": 6.741562500000001,
"endTime": 8.41,
"text": "لقد كنا في هذا لساعات\nالآن.",
"speaker": "Speaker 1",
"channel": 0
},
{
"startTime": 8.41,
"endTime": 10.200937500000002,
"text": "هل وجدت أي شيء مفيد\nفي أي من تلك الكتب؟",
"speaker": "Speaker 1",
"channel": 0
},
{
"startTime": 10.740937500000001,
"endTime": 13.27,
"text": "لا شيء واحد لويس.\nأنا متأكد من أنه يجب أن يكون هناك",
"speaker": "Speaker 0",
"channel": 0
}
],
"summary": "ملخص: كان المتحدثون يبحثون عن شيء ما في المكتبة لساعات..."
}
},
"sentiment_detection": {
"overall": "positive"
}
}
}
}