Created
March 2, 2023 09:56
-
-
Save yairhaimo/000a1f1486562be2938778233bcc1bd1 to your computer and use it in GitHub Desktop.
Summarize an Audio Clip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { supabaseUpload } from '@aigur/supabase'; | |
import { createClient, gpt3Prediction, stringToArrayBuffer, whisperApi } from '@aigur/client'; | |
const aigur = createClient({ | |
apiKeys: { | |
openai: process.env.OPENAI_KEY, | |
whisperapi: process.env.WHISPER_API, | |
} | |
}); | |
const voiceSummarizerPipeline = aigur.pipeline.create< | |
{ audio: string }, | |
{ summary: string } | |
>({ | |
id: 'voiceSummarizer', | |
flow: (flow) => | |
flow | |
.node(stringToArrayBuffer, ({ input }) => ({ | |
string: input.audio, | |
})) | |
.node(supabaseUpload, ({ prev }) => ({ | |
bucket: 'audio', | |
extension: 'mp3', | |
file: prev.arrayBuffer, | |
supabaseServiceKey: process.env.SUPABASE_SERVICE_KEY!, | |
supabaseUrl: process.env.SUPABASE_URL!, | |
})) | |
.node(whisperApi, ({ prev }) => ({ | |
audioUrl: prev.url, | |
})) | |
.node(gpt3Prediction, ({ prev }) => ({ | |
prompt: `${prev.text}\n\nTl;dr:`, | |
})) | |
.output(({ prev }) => ({ | |
summary: prev.text, | |
})), | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment