{"id":56677,"date":"2025-02-22T10:18:17","date_gmt":"2025-02-22T02:18:17","guid":{"rendered":"https:\/\/fwq.ai\/blog\/56677\/"},"modified":"2025-02-22T10:18:17","modified_gmt":"2025-02-22T02:18:17","slug":"%e5%85%8d%e8%b4%b9%e4%bd%bf%e7%94%a8-gemini-2-0-%e5%b0%86%e8%af%ad%e9%9f%b3%e8%bd%ac%e6%8d%a2%e4%b8%ba%e5%a4%9a%e5%8f%91%e8%a8%80%e4%ba%ba%e5%ad%97%e5%b9%95","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/56677\/","title":{"rendered":"\u514d\u8d39\u4f7f\u7528 Gemini 2.0 \u5c06\u8bed\u97f3\u8f6c\u6362\u4e3a\u591a\u53d1\u8a00\u4eba\u5b57\u5e55"},"content":{"rendered":"<p>\u8f6c\u5f55\u7684\u5b57\u5e55\u53ef\u4ee5\u5e26\u6709\u8bf4\u8bdd\u4eba\u6807\u7b7e\u548c\u79d2\u7ea7\u65f6\u95f4\u6233\uff0c\u5e76\u53ef\u4ee5\u51c6\u786e\u8bc6\u522b\u7b11\u58f0\u548c\u94c3\u58f0\uff0c\u5e76\u6b63\u786e\u8bc6\u522b\u6b4c\u66f2\u3002\u53d7\u8f93\u51fa  \u6240\u9650\uff0c\u6700\u957f\u5927\u7ea6\u53ef\u4ee5\u8f6c\u5f5515\u5206\u949f\u97f3\u9891\u3002\u53ef\u4ee5\u5728  \u4e2d\u5feb\u901f\u5c1d\u8bd5\uff0c\u6700\u540e\u6211\u4f1a\u9644\u4e0a\u4f7f\u7528\u514d\u8d39\u7684  2.0 \u6a21\u578b\u548c colab \u514d\u8d39\u5c06\u8bed\u97f3\u8f6c\u5f55\u4e3a\u5b57\u5e55\u6587\u672c\u7684\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p> <\/p>\n<p>&nbsp;<\/p>\n<h2>\u63d0\u793a\u8bcd<\/h2>\n<pre>\u751f\u6210\u8be5\u97f3\u9891\u7684\u8f6c\u5f55\u6587\u672c\u3002\u5305\u62ec\u65f6\u95f4\u6233\u5e76\u6807\u6ce8\u8bb2\u8bdd\u8005\u3002\r\n\u8bb2\u8bdd\u8005\u5305\u62ec\uff1a\r\n- \u5c0f\u7f8e\r\n\u793a\u4f8b\uff1a\r\n[00:00] Brady: Hello there.\r\n[00:02] Tim: Hi Brady.\r\n\u52a1\u5fc5\u4f7f\u7528\u6b63\u786e\u7684\u8bb2\u8bdd\u8005\u59d3\u540d\u3002\u4f7f\u7528\u4f60\u4e4b\u524d\u8bc6\u522b\u7684\u59d3\u540d\u3002\u5982\u679c\u786e\u5b9e\u65e0\u6cd5\u786e\u5b9a\u8bb2\u8bdd\u8005\u59d3\u540d\uff0c\u5219\u7528\u5b57\u6bcd\u4ee3\u66ff\uff0c\u4f8b\u5982\u672a\u77e5\u8bb2\u8bdd\u8005\u53ef\u6807\u8bb0\u4e3a 'A'\uff0c\u53e6\u4e00\u4e2a\u672a\u77e5\u8bb2\u8bdd\u8005\u53ef\u6807\u8bb0\u4e3a 'B'\u3002\r\n\u5982\u679c\u6709\u97f3\u4e50\u6216\u77ed\u6682\u7684\u97f3\u4e50\u7247\u6bb5\u64ad\u653e\uff0c\u8bf7\u6807\u6ce8\u5982\u4e0b\uff1a\r\n[01:02] [MUSIC] \u6216 [01:02] [JINGLE]\r\n\u5982\u679c\u53ef\u4ee5\u8bc6\u522b\u64ad\u653e\u7684\u97f3\u4e50\u6216\u7247\u6bb5\u540d\u79f0\uff0c\u5219\u4f7f\u7528\u8be5\u540d\u79f0\uff0c\u4f8b\u5982\uff1a\r\n[01:02] [Firework by Katy Perry] \u6216 [01:02] [The Sofa Shop jingle]\r\n\u5982\u679c\u64ad\u653e\u7684\u662f\u5176\u4ed6\u58f0\u97f3\uff0c\u8bf7\u5c1d\u8bd5\u6807\u8bc6\u8be5\u58f0\u97f3\uff0c\u4f8b\u5982\uff1a\r\n[01:02] [Bell ringing]\r\n\u6bcf\u4e2a\u5b57\u5e55\u5185\u5bb9\u5e94\u5c3d\u91cf\u7b80\u77ed\uff0c\u6700\u591a\u51e0\u53e5\u7b80\u77ed\u7684\u53e5\u5b50\u3002\r\n\u5728\u8282\u76ee\u7ed3\u675f\u65f6\u6807\u6ce8 [END]\u3002\r\n\u4e0d\u8981\u4f7f\u7528\u4efb\u4f55 Markdown \u683c\u5f0f\uff0c\u4f8b\u5982\u52a0\u7c97\u6216\u659c\u4f53\u3002\r\n\u4ec5\u4f7f\u7528\u82f1\u6587\u5b57\u6bcd\uff0c\u9664\u975e\u4f60\u786e\u4fe1\u9700\u8981\u4f7f\u7528\u5176\u4ed6\u8bed\u8a00\u5b57\u7b26\u3002\r\n\u786e\u4fdd\u4f7f\u7528\u6b63\u786e\u7684\u5355\u8bcd\u5e76\u62fc\u5199\u51c6\u786e\u3002\u5229\u7528\u64ad\u5ba2\u7684\u4e0a\u4e0b\u6587\u6765\u5e2e\u52a9\u8bc6\u522b\u3002\r\n\u5982\u679c\u4e3b\u6301\u4eba\u8ba8\u8bba\u7535\u5f71\u3001\u4e66\u7c4d\u6216\u540d\u4eba\uff0c\u786e\u4fdd\u7535\u5f71\u3001\u4e66\u7c4d\u6216\u540d\u4eba\u7684\u540d\u79f0\u62fc\u5199\u6b63\u786e\u3002\"\"\")<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>colab\u4ee3\u7801<\/strong><\/p>\n<pre>%pip install google-genai jinja2\r\n\nimport os\r\nfrom google import genai\r\n\n# create client\r\napi_key = os.getenv(\"GEMINI_API_KEY\",\"xxx\")\r\nclient = genai.Client(api_key=api_key)\r\n\nfrom jinja2 import Template\r\n\n# path to the file to upload\r\nfile_path = \"..\/assests\/porsche.mp3\" # Repalce with your own file path\r\n\n# Upload the file to the File API\r\nfile = client.files.upload(file=file_path)\r\n\n# Generate a structured response using the \r\nprompt_template = Template(\"\"\"Generate a transcript of the episode. Include timestamps and identify speakers.\r\n\nSpeakers are: \r\n{% for speaker in speakers %}- {{ speaker }}{% if not loop.last %}\\n{% endif %}{% endfor %}\r\n\neg:\r\n[00:00] Brady: Hello there.\r\n[00:02] Tim: Hi Brady.\r\n\nIt is important to include the correct speaker names. Use the names you identified earlier. If you really don't know the speaker's name, identify them with a letter of the alphabet, eg there may be an unknown speaker 'A' and another unknown speaker 'B'.\r\n\nIf there is music or a short jingle playing, signify like so:\r\n[01:02] [MUSIC] or [01:02] [JINGLE]\r\n\nIf you can identify the name of the music or jingle playing then use that instead, eg:\r\n[01:02] [Firework by Katy Perry] or [01:02] [The Sofa Shop jingle]\r\n\nIf there is some other sound playing try to identify the sound, eg:\r\n[01:02] [Bell ringing]\r\n\nEach individual caption should be quite short, a few short sentences at most.\r\n\nSignify the end of the episode with [END].\r\n\nDon't use any markdown formatting, like bolding or italics.\r\n\nOnly use characters from the English alphabet, unless you genuinely believe foreign characters are correct.\r\n\nIt is important that you use the correct words and spell everything correctly. Use the context of the podcast to help.\r\nIf the hosts discuss something like a movie, book or celebrity, make sure the movie, book, or celebrity name is spelled correctly.\"\"\")\r\n\n# Define the speakers and render the prompt\r\nspeakers = [\"John\"]\r\nprompt = prompt_template.render(speakers=speakers)\r\n\nresponse = client.models.generate_content(\r\nmodel=\"gemini-2.0-flash\",\r\ncontents=[prompt, file],\r\n)\r\n\nprint(response.text)\r\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u8f6c\u5f55\u7684\u5b57\u5e55\u53ef\u4ee5\u5e26\u6709\u8bf4\u8bdd\u4eba\u6807\u7b7e\u548c\u79d2\u7ea7\u65f6\u95f4\u6233\uff0c\u5e76\u53ef\u4ee5\u51c6\u786e\u8bc6\u522b\u7b11\u58f0\u548c\u94c3\u58f0\uff0c\u5e76\u6b63\u786e\u8bc6\u522b\u6b4c\u66f2\u3002\u53d7\u8f93\u51fa \u6240\u9650\uff0c\u6700\u957f\u5927\u7ea6\u53ef\u4ee5\u8f6c\u5f5515\u5206\u949f\u97f3\u9891\u3002\u53ef\u4ee5\u5728 \u4e2d\u5feb\u901f\u5c1d\u8bd5\uff0c\u6700\u540e\u6211\u4f1a\u9644\u4e0a\u4f7f\u7528\u514d\u8d39\u7684 2.0 \u6a21\u578b\u548c colab \u514d\u8d39\u5c06\u8bed\u97f3\u8f6c\u5f55\u4e3a\u5b57\u5e55\u6587\u672c\u7684\u4ee3\u7801\u3002 &nbsp; \u63d0\u793a\u8bcd \u751f\u6210\u8be5\u97f3\u9891\u7684\u8f6c\u5f55\u6587\u672c\u3002\u5305\u62ec\u65f6\u95f4\u6233\u5e76\u6807\u6ce8\u8bb2\u8bdd\u8005\u3002 \u8bb2\u8bdd\u8005\u5305\u62ec\uff1a &#8211; \u5c0f\u7f8e \u793a\u4f8b\uff1a [00:00] Brady: Hello there. [00:02] Tim: Hi Brady. \u52a1\u5fc5\u4f7f\u7528\u6b63\u786e\u7684\u8bb2\u8bdd\u8005\u59d3\u540d\u3002\u4f7f\u7528\u4f60\u4e4b\u524d\u8bc6\u522b\u7684\u59d3\u540d\u3002\u5982\u679c\u786e\u5b9e\u65e0\u6cd5\u786e\u5b9a\u8bb2\u8bdd\u8005\u59d3\u540d\uff0c\u5219\u7528\u5b57\u6bcd\u4ee3\u66ff\uff0c\u4f8b\u5982\u672a\u77e5\u8bb2\u8bdd\u8005\u53ef\u6807\u8bb0\u4e3a &#8216;A&#8217;\uff0c\u53e6\u4e00\u4e2a\u672a\u77e5\u8bb2\u8bdd\u8005\u53ef\u6807\u8bb0\u4e3a &#8216;B&#8217;\u3002 \u5982\u679c\u6709\u97f3\u4e50\u6216\u77ed\u6682\u7684\u97f3\u4e50\u7247\u6bb5\u64ad\u653e\uff0c\u8bf7\u6807\u6ce8\u5982\u4e0b\uff1a [01:02] [MUSIC] \u6216 [01:02] [JINGLE] \u5982\u679c\u53ef\u4ee5\u8bc6\u522b\u64ad\u653e\u7684\u97f3\u4e50\u6216\u7247\u6bb5\u540d\u79f0\uff0c\u5219\u4f7f\u7528\u8be5\u540d\u79f0\uff0c\u4f8b\u5982\uff1a [01:02] [Firework by Katy Perry] \u6216 [01:02] [The Sofa Shop jingle] \u5982\u679c\u64ad\u653e\u7684\u662f\u5176\u4ed6\u58f0\u97f3\uff0c\u8bf7\u5c1d\u8bd5\u6807\u8bc6\u8be5\u58f0\u97f3\uff0c\u4f8b\u5982\uff1a [01:02] [Bell ringing] \u6bcf\u4e2a\u5b57\u5e55\u5185\u5bb9\u5e94\u5c3d\u91cf\u7b80\u77ed\uff0c\u6700\u591a\u51e0\u53e5\u7b80\u77ed\u7684\u53e5\u5b50\u3002 \u5728\u8282\u76ee\u7ed3\u675f\u65f6\u6807\u6ce8 [END]\u3002 \u4e0d\u8981\u4f7f\u7528\u4efb\u4f55 Markdown \u683c\u5f0f\uff0c\u4f8b\u5982\u52a0\u7c97\u6216\u659c\u4f53\u3002 \u4ec5\u4f7f\u7528\u82f1\u6587\u5b57\u6bcd\uff0c\u9664\u975e\u4f60\u786e\u4fe1\u9700\u8981\u4f7f\u7528\u5176\u4ed6\u8bed\u8a00\u5b57\u7b26\u3002 \u786e\u4fdd\u4f7f\u7528\u6b63\u786e\u7684\u5355\u8bcd\u5e76\u62fc\u5199\u51c6\u786e\u3002\u5229\u7528\u64ad\u5ba2\u7684\u4e0a\u4e0b\u6587\u6765\u5e2e\u52a9\u8bc6\u522b\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-56677","post","type-post","status-publish","format-standard","hentry","category-ai"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/56677","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=56677"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/56677\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=56677"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=56677"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=56677"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}