diff --git a/examples/Podcast_and_Audio_Transcription.ipynb b/examples/Podcast_and_Audio_Transcription.ipynb new file mode 100644 index 000000000..508ec978d --- /dev/null +++ b/examples/Podcast_and_Audio_Transcription.ipynb @@ -0,0 +1,531 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "Hfb0zeHYnwtC" + }, + "source": [ + "##### Copyright 2025 Google LLC." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "cellView": "form", + "id": "NeImViGqnv1b" + }, + "outputs": [], + "source": [ + "# @title Licensed under the Apache License, Version 2.0 (the \"License\");\n", + "# you may not use this file except in compliance with the License.\n", + "# You may obtain a copy of the License at\n", + "#\n", + "# https://www.apache.org/licenses/LICENSE-2.0\n", + "#\n", + "# Unless required by applicable law or agreed to in writing, software\n", + "# distributed under the License is distributed on an \"AS IS\" BASIS,\n", + "# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n", + "# See the License for the specific language governing permissions and\n", + "# limitations under the License." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "bxGr_x3MRA0z" + }, + "source": [ + "" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "ysy--KfNRrCq" + }, + "source": [ + "# Podcast and Audio Transcription with the Gemini API\n", + "\n", + "## Advanced Audio-to-Text Conversion \n", + "Gemini 2.0 transforms audio files (podcasts, interviews, call recordings) into **structured transcripts** with: \n", + "- **Precision timestamps** ([00:00] format) \n", + "- **Speaker identification** (labeled or auto-assigned as Speaker A/B) \n", + "- **Audio event detection**: \n", + " - Background music (with song recognition, e.g., `[02:15] [Firework by Katy Perry]`) \n", + " - Sound effects (e.g., `[01:30] [Bell ringing]`) \n", + " - Named jingles (e.g., `[00:45] [The Sofa Shop jingle]`) \n", + "\n", + "## Implementation Notes \n", + "1. **File Preparation**: \n", + " - Supports MP3/WAV formats \n", + " - Update `file_path` to your audio file location \n", + "2. **Output Format**: \n", + " - Clean text without markdown \n", + " - Terminates with `[END]` marker \n", + "3. **Accuracy**: \n", + " - Context-aware spelling (corrects names/titles) \n", + " - English-alphabet focused (non-English chars only when explicit) \n", + "\n", + "```python\n", + "# Example output snippet:\n", + "[00:00] Tom: Welcome to the podcast. \n", + "[00:03] Speaker A: Thanks for having me! \n", + "[00:06] [Coffee shop ambiance] \n", + "[01:30] [END]\n", + "```\n" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "id": "Ne-3gnXqR0hI" + }, + "outputs": [], + "source": [ + "%pip install -U -q \"google-genai>=1.0.0\"" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "id": "EconMHePQHGw" + }, + "outputs": [], + "source": [ + "from google import genai\n", + "\n", + "from IPython.display import Markdown" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "eomJzCa6lb90" + }, + "source": [ + "## Configure your API key\n", + "\n", + "To run the following cell, your API key must be stored it in a Colab Secret named `GOOGLE_API_KEY`. If you don't already have an API key, or you're not sure how to create a Colab Secret, see [Authentication](https://github.com/google-gemini/cookbook/blob/main/quickstarts/Authentication.ipynb) for an example." + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "id": "v-JZzORUpVR2" + }, + "outputs": [], + "source": [ + "from google.colab import userdata\n", + "GOOGLE_API_KEY = userdata.get('GOOGLE_API_KEY')\n", + "client = genai.Client(api_key=GOOGLE_API_KEY)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "id": "Ym4w9z3iWHlT" + }, + "outputs": [], + "source": [ + "MODEL_ID=\"gemini-2.0-flash\" # @param [\"gemini-2.0-flash-lite\",\"gemini-2.0-flash\",\"gemini-2.0-pro-exp-02-05\"] {\"allow-input\":true, isTemplate: true}" + ] + }, + { + "cell_type": "markdown", + "source": [ + "## Audio Transcription Example\n", + "\n", + "Now that you've configured your API key, let's walk through an example of how to use it for audio transcription.\n" + ], + "metadata": { + "id": "AtrPGWFp3xz-" + } + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "id": "J580DkQPVYYp", + "outputId": "2cd4af48-5497-4247-a6fd-ee2ad60c43f4", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "collapsed": true + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Requirement already satisfied: jinja2 in /usr/local/lib/python3.11/dist-packages (3.1.6)\n", + "Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.11/dist-packages (from jinja2) (3.0.2)\n" + ] + } + ], + "source": [ + "%pip install jinja2" + ] + }, + { + "cell_type": "code", + "source": [ + "import requests\n", + "\n", + "# URL of the audio file\n", + "file_path = \"https://storage.googleapis.com/generativeai-downloads/data/State_of_the_Union_Address_30_January_1961.mp3\"\n", + "\n", + "# Download and save the file locally\n", + "response = requests.get(file_path)\n", + "local_file_path = \"/tmp/audio.mp3\"\n", + "with open(local_file_path, \"wb\") as f:\n", + " f.write(response.content)" + ], + "metadata": { + "id": "Gym9HYt35IQL" + }, + "execution_count": 7, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "import os\n", + "\n", + "# Upload the file to the API\n", + "file = client.files.upload(file=local_file_path)\n", + "\n", + "# Remove the local copy after upload\n", + "os.remove(local_file_path)" + ], + "metadata": { + "id": "F5A2St8K5OXz" + }, + "execution_count": 8, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "from jinja2 import Template\n", + "\n", + "# Define the prompt template\n", + "prompt_template = Template(\"\"\"\n", + " Generate a transcript of the episode. Include timestamps and identify speakers.\n", + "\n", + " Speakers are:\n", + " {% for speaker in speakers %}- {{ speaker }}{% if not loop.last %}\\n{% endif %}{% endfor %}\n", + "\n", + " eg:\n", + " [00:00] Brady: Hello there.\n", + " [00:02] Tim: Hi Brady.\n", + "\n", + " It is important to include the correct speaker names. Use the names you identified earlier.\n", + " If you really don't know the speaker's name, identify them with a letter of the alphabet,\n", + " e.g., there may be an unknown speaker 'A' and another unknown speaker 'B'.\n", + "\n", + " If there is music or a short jingle playing, signify like so:\n", + " [01:02] [MUSIC] or [01:02] [JINGLE]\n", + "\n", + " If you can identify the name of the music or jingle playing then use that instead, e.g.:\n", + " [01:02] [Firework by Katy Perry] or [01:02] [The Sofa Shop jingle]\n", + "\n", + " If there is some other sound playing try to identify the sound, e.g.:\n", + " [01:02] [Bell ringing]\n", + "\n", + " Each individual caption should be quite short, a few short sentences at most.\n", + "\n", + " Signify the end of the episode with [END].\n", + "\n", + " Don't use any markdown formatting, like bolding or italics.\n", + "\n", + " Only use characters from the English alphabet, unless you genuinely believe\n", + " foreign characters are correct.\n", + "\n", + " It is important that you use the correct words and spell everything correctly.\n", + " Use the context of the podcast to help.\n", + "\n", + " If the hosts discuss something like a movie, book or celebrity,\n", + " make sure the movie, book, or celebrity name is spelled correctly.\n", + "\"\"\")\n", + "\n", + "# Define known speakers\n", + "speakers = [\"Tom\"]\n", + "prompt = prompt_template.render(speakers=speakers)" + ], + "metadata": { + "id": "OU8oy6qo5RG1" + }, + "execution_count": 9, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "# Generate content using Gemini API\n", + "response = client.models.generate_content(\n", + " model=MODEL_ID,\n", + " contents=[prompt, file],\n", + ")\n", + "\n", + "# Display the transcript\n", + "print(response.text)" + ], + "metadata": { + "id": "0_Nil3wj5UTT", + "outputId": "6866d38b-14e4-4caa-dac8-f5ede7285239", + "colab": { + "base_uri": "https://localhost:8080/" + } + }, + "execution_count": 10, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "[00:00] [State of the Union Address by John F Kennedy]\n", + "[00:02] Tom: The President's State of the Union address to a joint session of the Congress from the rostrum of the House of Representatives, Washington D.C., January 30th, 1961.\n", + "[00:25] Tom: Mr. Vice President, Members of the Congress, it is a pleasure to return from whence I came.\n", + "[00:41] Tom: You are among my oldest friends in Washington and this house is my oldest home.\n", + "[00:47] Tom: It was here.\n", + "[00:53] Tom: It was here more than 14 years ago that I first took the oath of federal office.\n", + "[01:00] Tom: It was here for 14 years that I gained both knowledge and inspiration from members of both parties in both houses, from your wise and generous leaders and from the pronouncements which I can, vividly recall sitting where you now sit, including the programs of two great presidents, the undimmed eloquence of Churchill, the soaring idealism of Nero, the steadfast words of General De Gaulle.\n", + "[01:40] Tom: To speak from this same historic rostrum is a sobering experience, to be back among so many friends is a happy one.\n", + "[01:48] Tom: I am confident that that friendship will continue.\n", + "[01:52] Tom: Our constitution wisely assigns both joined and separate roles to each branch of the government and a president and a Congress who hold each other in mutual respect will neither permit nor attempt any trespass.\n", + "[02:09] Tom: For my part, I shall withhold from neither the Congress nor the people any fact or report, past, present, or future, which is necessary for an informed judgement of our conduct and hazards.\n", + "[02:24] Tom: I shall neither shift the burden of executive decisions to the Congress, nor avoid responsibility for the outcome of those decisions.\n", + "[02:38] Tom: I speak today in an hour of national peril and national opportunity.\n", + "[02:45] Tom: Before my term has ended, we shall have to test anew whether a nation organized and governed such as ours can endure.\n", + "[02:55] Tom: The outcome is by no means certain.\n", + "[02:58] Tom: The answers are by no means clear.\n", + "[03:01] Tom: All of us together, this administration, this Congress, this nation must forge those answers.\n", + "[03:11] Tom: But today were I to offer, after little more than a week in office, detailed legislation to remedy every national ill, the Congress would rightly wonder whether the desire for speed had replaced the duty of responsibility.\n", + "[03:28] Tom: My remarks therefore will be limited, but they will also be candid.\n", + "[03:34] Tom: To state the facts frankly is not to despair the future nor indict the past.\n", + "[03:41] Tom: The prudent heir takes careful inventory of his legacies and gives a faithful accounting to those whom he owes an obligation of trust.\n", + "[03:53] Tom: And while the occasion does not call for another recital of our blessings and assets, we do have no greater asset than the willingness of a free and determined people through its elected officials to face all problems frankly and meet all dangers free from panic or fear.\n", + "[04:13] Tom: The present state of our economy is disturbing.\n", + "[04:17] Tom: We take office in the wake of seven months of recession, three and one half years of slack, seven years of diminished economic growth, and nine years of falling farm income.\n", + "[04:32] Tom: Business bankruptcies have reached their highest level since the Great Depression.\n", + "[04:38] Tom: Since 1951, farm income has been squeezed down by 25%.\n", + "[04:48] Tom: Save for a brief period in 1958, insured unemployment is at the highest peak in our history.\n", + "[04:57] Tom: Of some five and one half million Americans who are without jobs, more than 1 million have been searching for work for more than four months.\n", + "[05:07] Tom: And during each month, some 150,000 workers are exhausting their already meager jobless benefit rights.\n", + "[05:19] Tom: Nearly 1/8 of those who are without jobs live almost without hope in nearly 100 specially distressed and troubled areas.\n", + "[05:30] Tom: The rest include new school graduates, unable to use their talents, farmers, forced to give up their part time jobs which helped balance their family budgets, skilled and unskilled workers laid off in such important industries as metals, machinery, automobiles, and apparel.\n", + "[05:55] Tom: Our recovery from the 1958 recession moreover was anemic and incomplete.\n", + "[06:02] Tom: Our gross national product never regained its full potential.\n", + "[06:09] Tom: Unemployment never returned to normal levels.\n", + "[06:15] Tom: Maximum use of our national industrial capacity was never fully restored.\n", + "[06:21] Tom: In short, the American economy is in trouble.\n", + "[06:26] Tom: The most resourceful industrialized country on Earth ranks among the last in the rate of economic growth.\n", + "[06:34] Tom: Since last spring, our economic growth rate has actually declined.\n", + "[06:39] Tom: Business investment is in a decline.\n", + "[06:42] Tom: Profits have fallen below predicted levels.\n", + "[06:46] Tom: Construction is off.\n", + "[06:48] Tom: A million unsold automobiles are an inventory.\n", + "[06:55] Tom: Fewer people are working and the average work week has shrunk well below 40 hours.\n", + "[07:03] Tom: Yet prices have continued to rise, so that now too many Americans have less to spend for items that cost more to buy.\n", + "[07:14] Tom: Economic prophecy is at best an uncertain art, as demonstrated by the prediction one year ago from this same podium that 1960 would be and I quote, the most prosperous year in our history, unquote.\n", + "[07:30] Tom: Nevertheless, forecasts of continued slack and only slightly reduced unemployment through 1961 and 1962 have been made with alarming unanimity and this administration does not intend to stand helplessly by.\n", + "[07:54] Tom: We cannot afford to waste idle hours and empty plants while awaiting the re-end of the recession.\n", + "[08:01] Tom: We must show the world what a free economy can do to reduce unemployment, to put unused capacity to work, to spur new productivity, and to foster high and economic growth within a range of sound fiscal policies and relative price stability.\n", + "[08:23] Tom: I will propose to the Congress within the next 14 days measures to improve unemployment compensation through temporary increases in duration on a self supporting basis to provide more food for the families of the unemployed and to aid their needy children.\n", + "[08:43] Tom: To redevelop our areas of chronic labor surplus, to expand the services of the US employment office, to stimulate housing and construction, to secure more purchasing power for our lowest paid workers by raising and expanding the minimum wage, to offer tax incentives for sound plant investment, to increase the development of our natural resources, to encourage price stability and to take other steps aimed at ensuring a prompt recovery and paving the way for increased long range growth.\n", + "[09:33] Tom: This is not a partisan program concentrating on our weaknesses.\n", + "[09:37] Tom: It is, I hope, a national program to realize our national strength.\n", + "[09:49] Tom: Efficient expansion at home, stimulating the new plant and technology that can make our goods more competitive is also the key to the international balance of payment problem.\n", + "[10:02] Tom: Laying aside all talk and solutions, let us put that problem in its proper perspective.\n", + "[10:11] Tom: It is true that since 1958, the gap between the dollars we spend or invest abroad and the dollars return to us has substantially widened.\n", + "[10:24] Tom: This overall deficit in our balance of payments increased by nearly $11 billion in the last three years and holders of dollars abroad converted them to gold in such a quantity as to cause a total outflow of nearly $5 billion of gold from our reserves.\n", + "[10:43] Tom: The 1959 deficit was caused in large part by our failure of our exports to penetrate foreign markets, the result both of restrictions on our goods and our own uncompetitive prices.\n", + "[10:57] Tom: The 1960 deficit on the other hand was more the result of an increase in private capital outflow seeking new opportunity, higher return or speculative advantage abroad.\n", + "[11:12] Tom: Meanwhile, this country has continued to bear more than its share of the West military and foreign aid obligations.\n", + "[11:21] Tom: Under existing policies, another deficit of $2 billion is predicted for 1961, and individuals in those countries whose dollar position once depended on these deficits for improvement, now wonder aloud whether our gold reserves will remain sufficient to meet our own obligations.\n", + "[11:44] Tom: All this is cause for concern, but it is not cause for panic, for our monetary and financial position remains exceedingly strong.\n", + "[11:55] Tom: Including our drawing rights in the International Monetary Fund and the gold reserve held as backing for our currency and Federal Reserve deposits, we have some $22 billion in total gold stocks and other international monetary reserves and I now pledge that their full strength stands behind the value of the dollar for use if needed.\n", + "[12:20] Tom: Moreover, we hold large assets abroad.\n", + "[12:24] Tom: The total owe this nation far exceeds the claim upon our reserves and our exports once again substantially exceed our imports.\n", + "[12:36] Tom: In short, we need not and we shall not take any action to increase the dollar price of gold from $35 an ounce.\n", + "[12:51] Tom: To impose exchange controls, to reduce our anti-recession efforts, to fall back on restrictive trade policies or to weaken our commitments around the world.\n", + "[13:02] Tom: This administration will not distort the value of the dollar in any fashion and this is a commitment.\n", + "[13:14] Tom: Prudence and good sense do require however that new steps be taken to ease the payment deficits and prevent any gold crisis.\n", + "[13:24] Tom: Our success in world affairs has long depended in part upon foreign confidence in our ability to pay.\n", + "[13:33] Tom: A series of executive orders, legislative remedies, and cooperative efforts with our allies will get underway immediately aimed at attracting foreign investment and travel to this country, promoting American exports at stable prices and with more liberal government guarantees and financing, curbing tax and custom loopholes that encourage undue spending of private dollars abroad and through OECD, NATO and otherwise sharing with our allies all efforts to provide for the common defense of the free world and the hopes for growth of the less developed lands.\n", + "[14:36] Tom: While the current deficit lasts, ways will be found to ease our dollar outlays abroad without placing the full burden on the families of men who we've asked to serve our flag overseas.\n", + "[14:52] Tom: In short, whatever is required will be done to back up all our efforts abroad and to make certain that in the future as in the past, the dollar is as sound as a dollar.\n", + "[15:08] Tom: But more than our exchange of international payments is out of balance.\n", + "[15:13] Tom: The current federal budget for fiscal 1961 is almost certain to show a net deficit.\n", + "[15:21] Tom: The budget already submitted for fiscal 1962 will remain in balance only if the Congress enacts all the revenue measures requested and only if an earlier and sharper upturn in the economy than my economic advisors now think likely produces the tax revenues estimated.\n", + "[15:46] Tom: Nevertheless, a new administration must of necessity build on the spending and revenue estimates already submitted.\n", + "[15:55] Tom: Within that framework, barring the development of urgent national defense needs or a worsening of the economy, it is my current intention to advocate a program of expenditures which including revenue from a stimulation of the economy will not of and by themselves unbalance the earlier budget.\n", + "[16:18] Tom: However, we will do what must be done, for our national household is cluttered with unfinished and neglected tasks.\n", + "[16:27] Tom: Our cities are being engulfed in squalor.\n", + "[16:31] Tom: 12 long years after Congress declared our goal to be a decent home and a suitable environment for every American family, we still have 25 million Americans living in substandard homes.\n", + "[16:46] Tom: A new housing program under a new Housing and Urban Affairs Department will be needed this year.\n", + "[16:53] Tom: Our classrooms contain 2 million more children than they can properly have room for, taught by 90,000 teachers, not properly qualified to teach.\n", + "[17:04] Tom: 1/3 of our most promising high school graduates are financially unable to continue the development of their talents.\n", + "[17:13] Tom: The war babies of the 1940s, who overcrowded our schools in the 1950s are now descending in 1960 upon our colleges with two college students for everyone 10 years from now and our colleges are ill prepared.\n", + "[17:30] Tom: We lack the scientists, the engineers and the teachers, our world obligations require.\n", + "[17:37] Tom: We have neglected oceanography, saline water conversion and the basic research that lies at the root of all progress.\n", + "[17:47] Tom: Federal grants for both higher and public school education can no longer be delayed.\n", + "[17:58] Tom: Medical research has achieved new wonders, but these wonders are too often beyond the reach of too many people owing to a lack of income, particularly among the aged, a lack of hospital beds, a lack of nursing homes, and a lack of doctors and dentists.\n", + "[18:20] Tom: Measures to provide health care for the aged under social security and to increase the supply of both facilities and personnel must be undertaken this year.\n", + "[18:35] Tom: Our supply of clean water is dwindling.\n", + "[18:39] Tom: Organized and juvenile crime cost the taxpayers millions of dollars every year, making it essential that we have improved enforcement and new legislative safeguards.\n", + "[18:53] Tom: The denial of constitutional rights to some of our fellow Americans on account of race at the ballot box and elsewhere disturbs the national conscience and subjects us to the charge of world opinion that our democracy is not equal to the high promise of our heritage.\n", + "[19:12] Tom: Morality in private business has not been sufficiently spurred by morality in public business.\n", + "[19:19] Tom: A host of problems and projects in all 50 states, though not possible to include in this message deserves and will receive the attention of both the Congress and the executive branch.\n", + "[19:30] Tom: On most of these matters, messages will be sent to the Congress within the next two weeks.\n", + "[19:36] Tom: But all these problems pale when placed besides those which confront us around the world.\n", + "[19:44] Tom: No man entering upon this office, regardless of his party, regardless of his previous service in Washington, could fail to be staggered upon learning even in this brief 10 day period, the harsh enormities of the trials through which we must pass in the next four years.\n", + "[20:05] Tom: Each day the crises multiply, each day their solution grows more difficult, each day we draw nearer the hour of maximum danger as weapons spread and hostile forces grow stronger.\n", + "[20:19] Tom: I feel I must inform the Congress that our analysis over the next last 10 days make it clear that in each of the principal areas of crisis, the tide of events has been running out and time has not been our friend.\n", + "[20:36] Tom: In Asia, the relentless pressures of the Chinese communist menace the security of the entire area from the borders of India and South Vietnam to the jungles of Laos, struggling to protect its newly won independence.\n", + "[20:53] Tom: We seek in Laos what we seek in all Asia and indeed in all of the world freedom for the people and independence for the government and this nation shall persevere in our pursuit of these objectives.\n", + "[21:14] Tom: In Africa, the Congo has been brutally torn by civil strife, political unrest, and public disorder.\n", + "[21:23] Tom: We shall continue to support the heroic efforts of the United Nations to restore peace and order, efforts which are now endangered by mounting tensions, unsolved problems, and decreasing support from many member states.\n", + "[21:40] Tom: In Latin America, communist agents seeking to exploit that region's peaceful revolution of hope have established a base on Cuba, only 90 miles from our shore.\n", + "[21:52] Tom: Our objection with Cuba is not over the people's drive for a better life.\n", + "[21:58] Tom: Our objection is to their domination by foreign and domestic tyrannies.\n", + "[22:14] Tom: Cuban social and economic reform should be encouraged.\n", + "[22:20] Tom: Questions of economics and trade policy can always be negotiated, but communist domination in this hemisphere can never be negotiated.\n", + "[22:35] Tom: We are pledged to work with our sister republics to free the Americas of all such foreign domination and all tyranny, working towards the goal of a free hemisphere of free governments extending from Cape Horn to the Arctic Circle.\n", + "[22:58] Tom: In Europe, our alliances are unfulfilled and in some disarray.\n", + "[23:04] Tom: The unity of NATO has been weakened by economic rivalry and partially eroded by national interest.\n", + "[23:13] Tom: It has not yet fully mobilized its resources nor fully achieved a common outlook.\n", + "[23:19] Tom: Yet no Atlantic power can meet on its own the mutual problems now facing us in defense, foreign aid, monetary reserves and a host of other areas and our close ties with those whose hopes and interests we share are among this nation's most powerful assets.\n", + "[23:40] Tom: Our greatest challenge is still the world that lies beyond the Cold War, but the first great obstacle is still our relations with the Soviet Union and communist China.\n", + "[23:51] Tom: We must never be lulled into believing that either power has yielded its ambitions for world domination, ambitions which they forcefully restated only a short time ago.\n", + "[24:04] Tom: On the contrary, our task is to convince them that aggression and subversion will not be profitable routes to pursue these ends.\n", + "[24:14] Tom: Open and peaceful competition for prestige, for markets, for scientific achievement, even for men's minds is something else again.\n", + "[24:24] Tom: For if freedom and communism would compete for man's allegiance in a world at peace, I would look to the future with ever increasing confidence.\n", + "[24:41] Tom: To meet this array of challenges to fulfill the role we cannot avoid on the world scene, we must reexamine and revise our whole arsenal of tools.\n", + "[24:53] Tom: One must not overshadow the other.\n", + "[24:57] Tom: On the presidential coat of arms, the American eagle holds in his right talent the olive branch, while in his left he holds a bundle of arrows.\n", + "[25:07] Tom: We intend to give equal attention to both.\n", + "[25:16] Tom: First, we must strengthen our military tools.\n", + "[25:20] Tom: We are moving into a period of uncertain risk and great commitment in which both the military and diplomatic possibilities require a free world force so powerful as to make any aggression clearly futile.\n", + "[25:35] Tom: Yet in the past, lack of a consistent, coherent military strategy, the absence of basic assumptions about our national requirements, and the faulty estimate and duplication arising from inner service rivalries have all made it difficult to assess accurately how adequate or inadequate our defenses really are.\n", + "[26:00] Tom: I have therefore instructed the Secretary of Defense to reappraise our entire defense strategy, our ability to fulfill our commitments, the effectiveness, vulnerability and dispersal of our strategic bases, forces and warning systems, the efficiency and economy of our operation and organization, the elimination of obsolete bases and installations and the adequacy, modernization and mobility of our present conventional and nuclear forces and weapon systems in the light of present and future dangers.\n", + "[26:47] Tom: I have asked for preliminary conclusions by the end of February and I then shall recommend whatever legislative, budgetary, or executive action is needed in the light of these conclusions.\n", + "[26:59] Tom: In the meantime, I have asked the defense secretary to initiate immediately three steps most clearly needed now.\n", + "[27:06] Tom: First, I have directed prompt attention to increase our airlift capacity.\n", + "[27:12] Tom: Obtaining additional air transport mobility and obtaining it now will better assure the ability of our conventional forces to respond without discrimination and speed with discrimination and speed to any problem at any spot on the globe at any moment's notice.\n", + "[27:33] Tom: In particular, it will enable us to meet any deliberate effort to avoid or divert our forces by starting limited wars in widely scattered parts of the globe.\n", + "[27:48] Tom: B, I have directed prompt action to step up our Polaris submarine program.\n", + "[27:56] Tom: Using unobligated shipbuilding funds now to let contracts originally scheduled for the next fiscal year will build and place on station at least nine months earlier than planned, substantially more units of a crucial deterrent.\n", + "[28:17] Tom: A fleet that will never attack first, but possess sufficient power of retaliation concealed beneath the sea to discourage any aggressor from launching an attack upon our security.\n", + "[28:34] Tom: C, I have directed prompt action to accelerate our entire missile program.\n", + "[28:41] Tom: Until the Secretary of Defense's reappraisal is completed, the emphasis here will be largely on improved organization and decision making.\n", + "[28:52] Tom: On cutting down the wasteful duplications and the time lag that have handicapped our whole family of missiles.\n", + "[29:00] Tom: If we are to keep the peace, we need an invulnerable missile force powerful enough to deter any aggressor from even threatening an attack that he would know could not destroy enough of our own forces to prevent his own destruction.\n", + "[29:19] Tom: For as I said upon taking the oath of office, only when our arms are sufficient beyond doubt, can we be certain beyond doubt that they will never be employed.\n", + "[29:34] Tom: Secondly, we must improve our economic tools.\n", + "[29:38] Tom: Our role is essential and unavoidable in the construction of a sound and expanding economy for the entire non-communist world, helping other nations build the strength to meet their own problems, to satisfy their own aspirations, to surmount their own dangers.\n", + "[30:01] Tom: The problems in achieving this goal are towering and unprecedented.\n", + "[30:05] Tom: The response must be towering and unprecedented as well.\n", + "[30:11] Tom: Much as lend lease and the Marshall Plan were in earlier years, which brought such fruitful results.\n", + "[30:18] Tom: I intend to ask the Congress for authority to establish a new and more effective program for assisting the economic, educational and social development of other countries and continents.\n", + "[30:36] Tom: That program must stimulate and take more effectively into account the contributions of our allies and provide central policy direction for all our own programs that now so often overlap, conflict, or diffuse our energies and resources.\n", + "[30:57] Tom: Such a program compared to past programs will require more flexibility for short run emergencies.\n", + "[31:04] Tom: More commitment to long term development.\n", + "[31:08] Tom: New attention to education at all levels.\n", + "[31:13] Tom: Greater emphasis on the recipient nation's role, their effort, their purpose with greater social justice for their people, a broader distribution and participation by their people and more efficient public administration and more efficient tax systems of their own and orderly planning for national and regional development instead of a piecemeal approach.\n", + "[31:44] Tom: I hope the Senate will take early action approving the convention establishing the organization for economic cooperation and development.\n", + "[31:55] Tom: This will be an important instrument in sharing with our allies this development effort, working towards the time when each nation will contribute in proportion to its ability to pay.\n", + "[32:10] Tom: For while we are prepared to assume our full share of these huge burdens, we cannot and must not be expected to bear them alone.\n", + "[32:27] Tom: To our sister Republics of the South, we have pledged a new alliance for progress.\n", + "[32:36] Tom: Our goal is a free and prosperous Latin America, realizing for all its states and all its citizens, a degree of economic and social progress that matches their historic contributions of culture, intellect, and liberty.\n", + "[32:58] Tom: To start this nation's role at this time in that alliance of neighbors, I am recommending the following, that the Congress appropriate in full the $500 million fund pledged by the Act of Bogotá to be used not as an instrument of the Cold War, but as a first step in the sound development of the Americas.\n", + "[33:23] Tom: That a new interdepartmental task force be established under the leadership of the Department of State to coordinate at the highest level all policies and programs of concern to the Americas.\n", + "[33:38] Tom: That our delegates to the OAS, working with those of other members, strengthen that body as an instrument to preserve the peace and to prevent foreign domination anywhere in the hemisphere.\n", + "[33:52] Tom: That in cooperation with other nations, we launch a new hemispheric attack on illiteracy and an adequate educational opportunities at all levels and finally that a food for peace mission be sent immediately to Latin America to explore ways in which our vast food abundance can be used to help hunger and malnutrition in certain areas of suffering in our own hemisphere.\n", + "[34:32] Tom: This administration is expanding its food for peace program in every possible way.\n", + "[34:38] Tom: The product of our abundance must be used more effectively to relieve hunger and help economic growth in all corners of the globe.\n", + "[34:50] Tom: And I have asked the director of this program to recommend additional ways in which these surpluses can advance the interests of world peace, including the establishment of world food reserves.\n", + "[35:02] Tom: And even more valuable national asset is our reservoir of dedicated men and women, not only at our college campuses, but in every age group who have indicated their desire to contribute their skills, their efforts and a part of their lives to the fight for world order.\n", + "[35:20] Tom: We can mobilize this talent through the formation of a national peace core enlisting the services of all those with desire and capacity to help foreign lands meet their urgent needs for trained personnel.\n", + "[35:34] Tom: Finally, while our attention is centered on the development of the non-communist world, we must never forget our hopes for the ultimate freedom and welfare of the Eastern European people.\n", + "[35:51] Tom: In order to be prepared to help reestablish historic ties of friendship, I am asking the Congress for increased discretion to use economic tools in this area whenever this is found to be clearly in the national interest.\n", + "[36:08] Tom: This will require amendment of the Mutual Defense Assistance Control Act along the lines I proposed as a member of the Senate and upon which the Senate voted last summer.\n", + "[36:21] Tom: Meanwhile, I hope to explore with the Polish government the possibility of using our frozen Polish funds on projects of peace that will demonstrate our abiding friendship and interest in the people of Poland.\n", + "[36:39] Tom: Third, we must sharpen our political and diplomatic tools.\n", + "[36:43] Tom: The means of cooperation and agreement on which an enforceable world order must ultimately rest.\n", + "[36:51] Tom: I have already taken steps to coordinate and expand our disarmament effort to increase our programs of research and study and to make arms control a central goal of our national policy under my direction.\n", + "[37:11] Tom: The deadly arms race and the huge resources it absorbs have too long overshadowed all else we must do.\n", + "[37:19] Tom: We must prevent that arms racing from spreading to new nations to new nuclear power, powers and to the outer reaches of space.\n", + "[37:29] Tom: We must make certain that our negotiators are better informed and better prepared to formulate workable proposals of our own and to make sound judgement about the proposals of others.\n", + "[37:41] Tom: I have asked the other governments concerned to agree to a reasonable delay in the talks on a nuclear test ban and it is our intention to resume negotiations prepared to reach a final agreement with any nation that is equally willing to agree to an effective and enforceable treaty.\n", + "[38:01] Tom: We must increase our support of the United Nations as an instrument to end the Cold War instead of an arena in which to fight it.\n", + "[38:10] Tom: In recognition of its increasing importance and the doubling of its membership, we are enlarging and strengthening our own mission to the UN.\n", + "[38:19] Tom: We shall help ensure that it is properly financed.\n", + "[38:22] Tom: We shall work to see that the integrity of the office of the Secretary General is maintained.\n", + "[38:36] Tom: And I would address a special plea to the smaller nations of the world to join with us in strengthening this organization, which is far more essential to their security than it is to ours.\n", + "[38:50] Tom: The only body in the world where no nation need be powerful to be secure, where every nation has an equal voice and where any nation can exert influence not according to the strength of its armies, but according to the strength of its ideas.\n", + "[39:07] Tom: It deserves the support of all.\n", + "[39:18] Tom: Finally, this administration intends to explore promptly all possible areas of cooperation with the Soviet Union and other nations to invoke the wonders of science instead of its terrors.\n", + "[39:33] Tom: Specifically, I now invite all nations, including the Soviet Union to join with us in developing a weather prediction program in a new communications satellite program and in preparation for probing the distant planets of Mars and Venus, probes which may someday unlock the deepest secrets of the universe.\n", + "[39:55] Tom: Today, this country is ahead in the science and technology of space, while the Soviet Union is ahead in the capacity.\n", + "[40:07] Tom: While the Soviet Union is ahead in the capacity to lift large vehicles into orbit.\n", + "[40:15] Tom: Both nations would help themselves as well as other nations by removing these endeavors from the bitter and wasteful competition of the Cold War.\n", + "[40:32] Tom: The United States would be willing to join with the Soviet Union and the scientists of all nations in a greater effort to make the fruits of this new knowledge available to all and beyond that in an effort to extend farm technology to hungry nations.\n", + "[40:52] Tom: To wipe out disease, to increase the exchanges of scientists and knowledge and our make our own laboratories available to technicians of other lands who lack the facilities to pursue their own work, where nature makes natural allies of us all.\n", + "[41:07] Tom: We can demonstrate that beneficial relations are possible even with those with whom we most deeply disagree and this must someday be the basis of world peace and world law.\n", + "[41:27] Tom: I have commented on the state of the domestic economy, our balance of payments, our federal and social budget and the state of the world.\n", + "[41:36] Tom: I would like to conclude with a few remarks about the state of the executive branch.\n", + "[41:41] Tom: We have found it full of honest and useful public servants, but their capacity to act decisively at the exact time action is needed has too often been muffled in the morass of committees, timidity and fictitious theories which have created a growing gap between decision and execution, between planning and reality.\n", + "[42:10] Tom: In a time of rapidly deteriorating situations at home and abroad, this is bad for the public service and particularly bad for the country and we mean to make a change.\n", + "[42:27] Tom: I have pledged myself and my colleagues in the cabinet to a continuous encouragement of initiative, responsibility, and energy in serving the public interest.\n", + "[42:40] Tom: Let every public servant know, whether his post is high or low, that a man's rank and reputation in this administration will be determined by the size of the job he does and not by the size of his staff, his office, or his budget.\n", + "[43:13] Tom: Let it be clear that this administration recognizes the value of dissent and daring that we greet healthy controversy as the hallmark of healthy change.\n", + "[43:24] Tom: Let the public service be a proud and lively career and let every man and woman who works in any area of our national government, in any branch, at any level be able to say with pride and with honor in future years, I served the United States government in that hour of our nation's need.\n", + "[43:53] Tom: For only with complete dedication by us all to the national interest can we bring our country through the troubled years that lie ahead.\n", + "[44:00] Tom: Our problems are critical.\n", + "[44:02] Tom: The tide is unfavorable.\n", + "[44:05] Tom: The news will be worse before it is better and while hoping and working for the best, we should prepare ourselves now for the worst.\n", + "[44:16] Tom: We cannot escape our dangers, neither must we let them drive us into panic or narrow isolation.\n", + "[44:23] Tom: In many areas of the world where the balance of power already rest with our adversaries, the forces of freedom are sharply divided.\n", + "[44:34] Tom: It is one of the ironies of our time that the techniques of a harsh and repressive system should be able to instill discipline and order in its servants while the blessings of liberty have too often stood for privilege, materialism and a life of ease, but I have a different view of liberty.\n", + "[44:59] Tom: Life in 1961 will not be easy.\n", + "[45:03] Tom: Wishing it, predicting it, even asking for it will not make it so.\n", + "[45:09] Tom: There will be further setbacks before the tide is turned, but turn it we must.\n", + "[45:17] Tom: The hopes of all mankind rest upon us.\n", + "[45:20] Tom: Not simply upon those of us in this chamber, but upon the peasant in Laos, the fisherman in Nigeria, the exile from Cuba, the spirit that moves every man in nation who shares our hopes for freedom and the future and in the final analysis, they rest most of all upon the pride and perseverance of our fellow citizens of the Great Republic.\n", + "[45:51] Tom: In the words of a great president, whose birthday we honor today, closing his final state of the union message 16 years ago, we pray that we may be worthy of the unlimited opportunities that God has given us.\n", + "[46:06] [END]\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "## Next Steps\n", + "\n", + "Enhance the transcription by adding speaker diarization, summarization, or sentiment analysis. You can also build a simple Streamlit app for interactive playback and transcript search.Try supporting multiple languages or fine-tuning prompts for better formatting and accuracy.\n" + ], + "metadata": { + "id": "YYq-GXRtt6kq" + } + } + ], + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file diff --git a/examples/README.md b/examples/README.md index 6f2e92e43..8ef3676c2 100644 --- a/examples/README.md +++ b/examples/README.md @@ -29,6 +29,8 @@ This is a collection of fun and helpful examples for the Gemini API. | [Virtual Try-on](./Virtual_Try_On.ipynb) | A Virtual Try-On application that uses Gemini 2.0 for 2D object detection to identify outfits in images and Imagen 3 for generating and inpainting new outfits. | Spatial Understanding | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/Virtual_Try_On.ipynb) | | [Talk to documents](./Talk_to_documents_with_embeddings.ipynb) | Use embeddings to search through a custom database. | Embeddings | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/Talk_to_documents_with_embeddings.ipynb) | | [Entity extraction](./Entity_Extraction.ipynb) | Use Gemini API to speed up some of your tasks, such as searching through text to extract needed information. Entity extraction with a Gemini model is a simple query, and you can ask it to retrieve its answer in the form that you prefer. | Embeddings | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/Entity_Extraction.ipynb) | +| [Podcast and Audio Transcription](https://github.com/SonjeVilas/cookbook/blob/pod_aud_transcription/Podcast_and_Audio_Transcription.ipynb) | Transcribe podcasts or audio using Gemini, and generate summaries or Q&A | Audio, Transcription, Summarization | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/SonjeVilas/cookbook/blob/pod_aud_transcription/Podcast_and_Audio_Transcription.ipynb) | + ---