Skip to content

Commit

Permalink
Fix colab
Browse files Browse the repository at this point in the history
  • Loading branch information
ionic-bond committed Nov 22, 2024
1 parent 0370e54 commit 3a65394
Showing 1 changed file with 75 additions and 74 deletions.
149 changes: 75 additions & 74 deletions stream_translator.ipynb
Original file line number Diff line number Diff line change
@@ -1,77 +1,78 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "view-in-github"
},
"source": [
"<a href=\"https://colab.research.google.com/github/ionic-bond/stream-translator-gpt/blob/main/stream_translator.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"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": [
"<a href=\"https://colab.research.google.com/github/ionic-bond/stream-translator-gpt/blob/main/stream_translator.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
"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
}

0 comments on commit 3a65394

Please sign in to comment.