import os
import assemblyai
from assemblyai.prerecorded.v2 import Transcript
# `Transcript.get_by_id()` uses the default client, which reads the global settings.
assemblyai.settings.api_key = os.environ["ASSEMBLYAI_API_KEY"]
transcript = Transcript.get_by_id("<TRANSCRIPT_ID>")
sentences = transcript.get_sentences()
print(len(sentences), sentences[0].text){
"sentences": [
{
"text": "Smoke from hundreds of wildfires in Canada is triggering air quality alerts throughout the US.",
"start": 250,
"end": 6350,
"confidence": 0.72412,
"words": [
{
"text": "Smoke",
"start": 250,
"end": 650,
"confidence": 0.72412,
"speaker": null
},
{
"text": "from",
"start": 730,
"end": 1022,
"confidence": 0.99996,
"speaker": null
},
{
"text": "hundreds",
"start": 1076,
"end": 1466,
"confidence": 0.99992,
"speaker": null
},
{
"text": "of",
"start": 1498,
"end": 1646,
"confidence": 1,
"speaker": null
}
],
"speaker": null
},
{
"text": "Skylines from Maine to Maryland to Minnesota are gray and smoggy.",
"start": 6500,
"end": 11050,
"confidence": 0.99819,
"words": [
{
"text": "Skylines",
"start": 6500,
"end": 7306,
"confidence": 0.99819,
"speaker": null
},
{
"text": "from",
"start": 7338,
"end": 7534,
"confidence": 0.99987,
"speaker": null
},
{
"text": "Maine",
"start": 7572,
"end": 7962,
"confidence": 0.9972,
"speaker": null
},
{
"text": "to",
"start": 8026,
"end": 8206,
"confidence": 1,
"speaker": null
},
{
"text": "Maryland",
"start": 8228,
"end": 8650,
"confidence": 0.5192,
"speaker": null
},
{
"text": "to",
"start": 8730,
"end": 8926,
"confidence": 1,
"speaker": null
}
],
"speaker": null
}
],
"id": "d5a3d302-066e-43fb-b63b-8f57baf185db",
"confidence": 0.9579390654205628,
"audio_duration": 281
}{
"error": "This is a sample error message"
}{
"error": "Authentication error, API token missing/invalid"
}{
"error": "Not found"
}{
"error": "Too Many Requests"
}{
"error": "Internal server error. Please retry your request. If the error persists, please contact support@assemblyai.com for more information."
}API reference
Get transcript sentences
To retrieve your transcriptions on our EU server, replace
api.assemblyai.com with api.eu.assemblyai.com.GET
/
v2
/
transcript
/
{transcript_id}
/
sentences
import os
import assemblyai
from assemblyai.prerecorded.v2 import Transcript
# `Transcript.get_by_id()` uses the default client, which reads the global settings.
assemblyai.settings.api_key = os.environ["ASSEMBLYAI_API_KEY"]
transcript = Transcript.get_by_id("<TRANSCRIPT_ID>")
sentences = transcript.get_sentences()
print(len(sentences), sentences[0].text){
"sentences": [
{
"text": "Smoke from hundreds of wildfires in Canada is triggering air quality alerts throughout the US.",
"start": 250,
"end": 6350,
"confidence": 0.72412,
"words": [
{
"text": "Smoke",
"start": 250,
"end": 650,
"confidence": 0.72412,
"speaker": null
},
{
"text": "from",
"start": 730,
"end": 1022,
"confidence": 0.99996,
"speaker": null
},
{
"text": "hundreds",
"start": 1076,
"end": 1466,
"confidence": 0.99992,
"speaker": null
},
{
"text": "of",
"start": 1498,
"end": 1646,
"confidence": 1,
"speaker": null
}
],
"speaker": null
},
{
"text": "Skylines from Maine to Maryland to Minnesota are gray and smoggy.",
"start": 6500,
"end": 11050,
"confidence": 0.99819,
"words": [
{
"text": "Skylines",
"start": 6500,
"end": 7306,
"confidence": 0.99819,
"speaker": null
},
{
"text": "from",
"start": 7338,
"end": 7534,
"confidence": 0.99987,
"speaker": null
},
{
"text": "Maine",
"start": 7572,
"end": 7962,
"confidence": 0.9972,
"speaker": null
},
{
"text": "to",
"start": 8026,
"end": 8206,
"confidence": 1,
"speaker": null
},
{
"text": "Maryland",
"start": 8228,
"end": 8650,
"confidence": 0.5192,
"speaker": null
},
{
"text": "to",
"start": 8730,
"end": 8926,
"confidence": 1,
"speaker": null
}
],
"speaker": null
}
],
"id": "d5a3d302-066e-43fb-b63b-8f57baf185db",
"confidence": 0.9579390654205628,
"audio_duration": 281
}{
"error": "This is a sample error message"
}{
"error": "Authentication error, API token missing/invalid"
}{
"error": "Not found"
}{
"error": "Too Many Requests"
}{
"error": "Internal server error. Please retry your request. If the error persists, please contact support@assemblyai.com for more information."
}Authorizations
Path Parameters
ID of the transcript
Response
Exported sentences
The unique identifier for the transcript
The confidence score for the transcript
Required range:
0 <= x <= 1The duration of the audio file in seconds
An array of sentences in the transcript
Show child attributes
Show child attributes
Was this page helpful?
⌘I