From 3a653944c47c1f09f9af86711fb4f9e5004488dc Mon Sep 17 00:00:00 2001 From: ionic-bond Date: Fri, 22 Nov 2024 16:29:49 +0800 Subject: [PATCH] Fix colab --- stream_translator.ipynb | 149 ++++++++++++++++++++-------------------- 1 file changed, 75 insertions(+), 74 deletions(-) diff --git a/stream_translator.ipynb b/stream_translator.ipynb index d3cb4fc..c535061 100644 --- a/stream_translator.ipynb +++ b/stream_translator.ipynb @@ -1,77 +1,78 @@ { - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "colab_type": "text", - "id": "view-in-github" - }, - "source": [ - "\"Open" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "1YobI37NrHO3" - }, - "outputs": [], - "source": [ - "!nvidia-smi" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "qjcs6q2CsH-N" - }, - "outputs": [], - "source": [ - "# @title Install\n", - "!pip install stream-translator-gpt" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "kIFl41YXsLr2" - }, - "outputs": [], - "source": [ - "# @title Run\n", - "URL = \"https://www.youtube.com/watch?v=r1dytEjbUqo\" # @param {type:\"string\"}\n", - "model = \"large\" # @param [\"small\", \"medium\", \"large\"] {allow-input: true}\n", - "language = \"ja\" # @param {type:\"string\"}\n", - "translation_prompt = \"Translate from Japanese to Chinese, only output the translation, do not output the original text\" # @param {type:\"string\"}\n", - "translation_engine = \"google\" # @param [\"openai\", \"google\"]\n", - "api_key = \"AIzaSyCPYq1F3WOlSGbWFcERf5qCv1hlo2SKOG8\" # @param {type:\"string\"}\n", - "translation_history_size = \"2\" # @param [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\"] {allow-input: true}\n", - "\n", - "!stream-translator-gpt \"{URL}\" --model {model} --language {language} \\\n", - " --use_faster_whisper \\\n", - " --gpt_translation_prompt \"{translation_prompt}\" --{translation_engine}_api_key \"{api_key}\" --gpt_translation_history_size {translation_history_size}" - ] - } - ], - "metadata": { - "accelerator": "GPU", - "colab": { - "authorship_tag": "ABX9TyPhxgmdjjNjPE1qGMaWxMeF", - "include_colab_link": true, - "provenance": [] - }, - "gpuClass": "standard", - "kernelspec": { - "display_name": "Python 3", - "name": "python3" - }, - "language_info": { - "name": "python" - } + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "view-in-github" + }, + "source": [ + "\"Open" + ] }, - "nbformat": 4, - "nbformat_minor": 0 + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "1YobI37NrHO3" + }, + "outputs": [], + "source": [ + "!nvidia-smi" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "qjcs6q2CsH-N" + }, + "outputs": [], + "source": [ + "# @title Install\n", + "!pip install stream-translator-gpt\n", + "!pip install ctranslate2==4.4.0" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "kIFl41YXsLr2" + }, + "outputs": [], + "source": [ + "# @title Run\n", + "URL = \"https://www.youtube.com/watch?v=r1dytEjbUqo\" # @param {type:\"string\"}\n", + "model = \"large\" # @param [\"small\", \"medium\", \"large\"] {allow-input: true}\n", + "language = \"ja\" # @param {type:\"string\"}\n", + "translation_prompt = \"Translate from Japanese to Chinese, only output the translation, do not output the original text\" # @param {type:\"string\"}\n", + "translation_engine = \"google\" # @param [\"openai\", \"google\"]\n", + "api_key = \"AIzaSyCPYq1F3WOlSGbWFcERf5qCv1hlo2SKOG8\" # @param {type:\"string\"}\n", + "translation_history_size = \"2\" # @param [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\"] {allow-input: true}\n", + "\n", + "!stream-translator-gpt \"{URL}\" --model {model} --language {language} \\\n", + " --use_faster_whisper \\\n", + " --gpt_translation_prompt \"{translation_prompt}\" --{translation_engine}_api_key \"{api_key}\" --gpt_translation_history_size {translation_history_size}" + ] + } + ], + "metadata": { + "accelerator": "GPU", + "colab": { + "authorship_tag": "ABX9TyPhxgmdjjNjPE1qGMaWxMeF", + "include_colab_link": true, + "provenance": [] + }, + "gpuClass": "standard", + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 }