Inspiration

I enjoy watching the Daily Show and Last Week Tonight and wanted to see if I could create an AI pipeline to generate topical jokes using Sonar API and video models

What it does

  1. The user can input a joke prompt (e.g. Tell me a joke about a product announced at Google I/O in the style of Jon Stewart)
  2. sonar-deep-research is used to research the topic and generate 5 jokes
  3. gpt-4.1 is used to select the "best" joke based on various criteria
  4. gpt-image-1 is used to generate an image of a comedian telling the joke which will later be animated
  5. gpt-4o-mini-tts is used to generate a voice saying the joke
  6. The image and the voice are used to generate a lip sync video using the cjwbw/sadtalker model on replicate
  7. Finally the fictions-ai/autocaption model is used to generate subtitles that highlight with the audio

How we built it

The initial app was generated with v0 using NextJS and Tailwind. Further edits were made using VSCode and copilot and old fashioned coding / debugging. I used models from Perplexity, OpenAI and replicate.

Challenges we ran into

The API calls to Sonar and the video generation models took too long to run on the free plan in Vercel so I couldn't host the video generation part of the project in the cloud and only use the basic sonar model there.

Some requests were failing when asking to generate an image of a person telling a joke "in the style of " due to OpenAI safety measures, so I had to add an indirect step to describe the celebrity before generating the image.

Accomplishments that we're proud of

Getting everything working in about 5 hours of work with a decent result. This was my first time heavily using AI to code and it worked pretty well.

What we learned

Learned a lot about how to string together multiple models to create a finished product and what the latest models from Sonar and OpenAI can do.

What's next for A1 LaughFactory

Add streaming or support for long running processes so I can finish deploying the final version to Vercel. I'd also like to experiment with changing the workflow to be agentic / tool based rather than procedurally calling each step of the pipeline. Ended up deploying it on render which allows longer running requests

Built With

Share this project:

Updates