Last active
June 27, 2025 20:29
-
-
Save luisquintanilla/c3aaaf794febc3d54e872679bb66d31e to your computer and use it in GitHub Desktop.
Gemma3n Audio Transcription Ollama
This file contains hidden or 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
| { | |
| "cells": [ | |
| { | |
| "cell_type": "markdown", | |
| "id": "ce742a3a", | |
| "metadata": {}, | |
| "source": [ | |
| "# Audio transcription with Gemma3n\n", | |
| "\n", | |
| "https://ai.google.dev/gemma/docs/core/huggingface_inference#audio" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 1, | |
| "id": "ea2d3e06", | |
| "metadata": { | |
| "language_info": { | |
| "name": "polyglot-notebook" | |
| }, | |
| "polyglot_notebook": { | |
| "kernelName": "csharp" | |
| } | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<div><div></div><div></div><div><strong>Installed Packages</strong><ul><li><span>Microsoft.Extensions.AI, 9.6.0</span></li><li><span>OllamaSharp, 5.2.3</span></li></ul></div></div>" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "#r \"nuget: OllamaSharp, 5.2.3\"\n", | |
| "#r \"nuget: Microsoft.Extensions.AI, 9.6.0\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 2, | |
| "id": "37d83a68", | |
| "metadata": { | |
| "language_info": { | |
| "name": "polyglot-notebook" | |
| }, | |
| "polyglot_notebook": { | |
| "kernelName": "csharp" | |
| } | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "using OllamaSharp;\n", | |
| "using Microsoft.Extensions.AI;" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 3, | |
| "id": "8efc0d32", | |
| "metadata": { | |
| "language_info": { | |
| "name": "polyglot-notebook" | |
| }, | |
| "polyglot_notebook": { | |
| "kernelName": "csharp" | |
| } | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "List<AIContent> messages = \n", | |
| " [\n", | |
| " new TextContent(\"Transcribe this audio and complete the statement\"),\n", | |
| " new UriContent(\"https://ai.google.dev/gemma/docs/audio/roses-are.wav\", \"audio/wav\")\n", | |
| " ];" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "id": "8ebd5c3f", | |
| "metadata": {}, | |
| "source": [ | |
| "## Ollama\n", | |
| "\n", | |
| "NOTE: As of 06-2025, only text generation works with Gemma 3n" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 4, | |
| "id": "118d96a8", | |
| "metadata": { | |
| "language_info": { | |
| "name": "polyglot-notebook" | |
| }, | |
| "polyglot_notebook": { | |
| "kernelName": "csharp" | |
| } | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "IChatClient ollamaClient = new OllamaApiClient(\"http://localhost:11434\", \"gemma3n\");" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 5, | |
| "id": "054fa1c5", | |
| "metadata": { | |
| "language_info": { | |
| "name": "polyglot-notebook" | |
| }, | |
| "polyglot_notebook": { | |
| "kernelName": "csharp" | |
| } | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "var ollamaRes = await ollamaClient.GetResponseAsync(new ChatMessage(ChatRole.User,messages));" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 6, | |
| "id": "0764cce6", | |
| "metadata": { | |
| "language_info": { | |
| "name": "polyglot-notebook" | |
| }, | |
| "polyglot_notebook": { | |
| "kernelName": "csharp" | |
| } | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Please **provide me with the audio!** I need the audio file or a link to the audio to be able to transcribe it and complete the statement. \n", | |
| "\n", | |
| "Once you provide the audio, I will:\n", | |
| "\n", | |
| "1. **Transcribe the audio:** I will convert the spoken words into text.\n", | |
| "2. **Identify the statement:** I will look for a statement that is being made or implied in the audio.\n", | |
| "3. **Complete the statement:** I will fill in any missing words or phrases to make the statement grammatically correct and meaningful.\n", | |
| "\n", | |
| "\n", | |
| "\n", | |
| "**Just paste the audio file here, or give me a link to it, and I'll get started!**\n", | |
| "\n", | |
| "\n", | |
| "\n" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "ollamaRes.Text" | |
| ] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": ".NET (C#)", | |
| "language": "C#", | |
| "name": ".net-csharp" | |
| }, | |
| "language_info": { | |
| "name": "polyglot-notebook" | |
| }, | |
| "polyglot_notebook": { | |
| "kernelInfo": { | |
| "defaultKernelName": "csharp", | |
| "items": [ | |
| { | |
| "aliases": [], | |
| "languageName": "csharp", | |
| "name": "csharp" | |
| } | |
| ] | |
| } | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 5 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment