Scheduled jobs can be used to consume video or audio from a source continuously. Two examples are given: one transcribes a radio webstream, and the other creates a media source first and then creates a job to capture the radio stream for audio playback.
Engines used in the examples for real-time transcription
The code example below creates a scheduled job that transcribes a radio stream in near real-time and returns the job ID. You can use the ID later to connect to a WebSocket and retrieve the output.
Engines used
These engines can be used in a flow for real-time transcription:
| Name | Description |
|---|
| TVR Engine | A stream URL is input and the contents are output |
| Output Writer Engine | Aggregate chunks and store them in a TDO |
| Transcription Engine | Run AI on the stream |
| Stream Ingestor Engine | Playback engine to store playback segments |
Example of real-time transcription job
The code example below creates a scheduled job that transcribes a radio stream in near real-time and returns the job ID. You can use the ID later to connect to a WebSocket and retrieve the output.
Variables to declare for createScheduledJob mutation
{
"name": "Transcription Schedule Job",
"clusterId": "rt-9d7a5d1b-ffe0-4d71-a982-190522cdf273", // Cluster ID from aiWARE Environment
"url": "https://stream.revma.ihrhls.com/zc389", // Stream URL
"startDateTime": "2022-01-20T22:20:00.000Z" // Time in UTC that you want the job to start.
}
GraphQL mutation to create the scheduled job
mutation CreateScheduleJobFromEngine(
$clusterId: ID!
$url: String!
$name: String!
$startDateTime: DateTime!
) {
createScheduledJob(
input: {
name: $name
runMode: Recurring
weeklyScheduleParts: [
{ scheduledDay: Monday, startTime: "04:00", stopTime: "17:00" }
{ scheduledDay: Tuesday, startTime: "04:00", stopTime: "17:00" }
{ scheduledDay: Wednesday, startTime: "04:00", stopTime: "17:00" }
{ scheduledDay: Thursday, startTime: "04:00", stopTime: "17:00" }
{ scheduledDay: Friday, startTime: "04:00", stopTime: "17:00" }
]
jobTemplates: {
clusterId: $clusterId
jobConfig :{
maxTDODuration: 5
}
taskTemplates: [
{
# TVR Adapter: stream URL contents in 32K chunks
engineId: "74dfd76b-472a-48f0-8395-c7e01dd7f255"
payload: {
url: $url
isLive: true
notUseCurl: true
chunkSize: 8000
allowOvershot: true
}
ioFolders: [{ referenceId: "tvrOut", mode: stream, type: output }]
}
{
# Engine: run AI on stream
engineId: "09f04ded-591d-4ef3-b45f-eb93b79c7c39"
payload: {
includePartial: false,
outputInRealTime: false
}
ioFolders: [
{ referenceId: "engineIn", mode: stream, type: input }
{ referenceId: "engineOut", mode: chunk, type: output }
]
}
{
# Output Writer: aggregate chunks and store in TDO
engineId: "8eccf9cc-6b6d-4d7d-8cb3-7ebf4950c5f3"
executionPreferences: { parentCompleteBeforeStarting: true }
ioFolders: [{ referenceId: "owIn", mode: chunk, type: input }]
}
]
routes: [
{
parentIoFolderReferenceId: "tvrOut"
childIoFolderReferenceId: "engineIn"
}
{
parentIoFolderReferenceId: "engineOut"
childIoFolderReferenceId: "owIn"
}
]
}
startDateTime: $startDateTime
}
) {
id
}
}
The response looks like this:
{
data: {
createScheduledJob: {
id: 1
}
}
}
Example of an audio capture job
This example creates a scheduled job for audio capture from a radio stream and then returns the job ID. You can use the ID later to connect to a WebSocket and hear the audio. To do this:
- Create a media source with a stream URL.
- Input the URL into the audio job payload.
- Create an audio job.
Engines used
These engines can be used to capture real-time audio for playback:
| Name | Description |
|---|
| TVR Engine | A stream URL is input and the contents are output |
| Stream Ingestor Engine | Playback engine to store playback segments |
Variables to declare for createMediaSource mutation
{
"name": "Stream URL Example 1", // Name of the media source.
"url": "https://stream.revma.ihrhls.com/zc389", // Stream URL
"timezone": "America/Los_Angeles" // The timezone that you want to use that will correlate with the scheduled job you create.
}
GraphQL mutation to create the media source
mutation CreateMediaSource($name: String!, $url: String!, $timezone: String!) {
createSource(
input: {
name: $name
sourceTypeId: "1" # Radio Stream Source Type
details: { liveTimezone: $timezone, radioStreamUrl: $url }
}
) {
id
}
}
The response looks like this:
{
data: {
createSource: {
id: 1
}
}
}
Variables to declare for scheduled job mutation
{
"name": "Transcription Schedule Job",
"clusterId": "rt-9d7a5d1b-ffe0-4d71-a982-190522cdf273", // Cluster ID from aiWARE Environment
"url": "https://stream.revma.ihrhls.com/zc389", // Stream URL
"sourceIdJob": 1, // The media source id
"sourceIdPayload": "1", // The media source id as a string
"startDateTime": "2022-01-20T22:20:00.000Z" // Time in UTC that you want the job to start.
}
GraphQL mutation to create the scheduled job
mutation CreateScheduleJobFromEngine(
$clusterId: ID!
$name: String!
$sourceIdJob: ID
$sourceIdPayload: String
$startDateTime: DateTime!
) {
createScheduledJob(
input: {
name: $name
runMode: Recurring
weeklyScheduleParts: [
{ scheduledDay: Monday, startTime: "04:00", stopTime: "17:00" }
{ scheduledDay: Tuesday, startTime: "04:00", stopTime: "17:00" }
{ scheduledDay: Wednesday, startTime: "04:00", stopTime: "17:00" }
{ scheduledDay: Thursday, startTime: "04:00", stopTime: "17:00" }
{ scheduledDay: Friday, startTime: "04:00", stopTime: "17:00" }
]
jobTemplates: {
clusterId: $clusterId
jobConfig: {
maxTDODuration: 5
sourceData: { sourceId: $sourceIdJob }
}
taskTemplates: [
{
# TVR Adapter: stream URL contents in 32K chunks
engineId: "74dfd76b-472a-48f0-8395-c7e01dd7f255"
payload: {
sourceId: $sourceIdPayload
isLive: true
notUseCurl: true
allowOvershot: true
}
ioFolders: [{ referenceId: "tvrOut", mode: stream, type: output }]
}
{
# Stream Ingestor 2 (SI2) Playback engine to store playback segments
engineId: "352556c7-de07-4d55-b33f-74b1cf237f25"
ioFolders: [
{ referenceId: "playbackInput", mode: stream, type: input }
]
executionPreferences: { parentCompleteBeforeStarting: true }
}
]
routes: [
{
parentIoFolderReferenceId: "tvrOut"
childIoFolderReferenceId: "playbackInput"
}
]
}
startDateTime: $startDateTime
}
) {
id
}
}
The response looks like this:
{
data: {
createScheduledJob: {
id: 2
}
}
}
What to do next
Connect to a WebSocket