Skip to content

Instantly share code, notes, and snippets.

@yairhaimo
Created March 2, 2023 10:00
Show Gist options
  • Save yairhaimo/1da02327ace381f7441fcd08efe9b74b to your computer and use it in GitHub Desktop.
Save yairhaimo/1da02327ace381f7441fcd08efe9b74b to your computer and use it in GitHub Desktop.
Summarize an Audio Clip
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