{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# pip install langdetect\n", "# pip install sentencepiece\n", "# pip install boto3\n", "# pip install awscli\n", "# pip install sacremoses" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "WARNING:tensorflow:From c:\\Users\\mered\\anaconda3\\Lib\\site-packages\\keras\\src\\losses.py:2976: The name tf.losses.sparse_softmax_cross_entropy is deprecated. Please use tf.compat.v1.losses.sparse_softmax_cross_entropy instead.\n", "\n" ] } ], "source": [ "import gradio as gr\n", "from transformers import pipeline, AutoTokenizer, TFAutoModelForSeq2SeqLM\n", "from dotenv import load_dotenv\n", "import os\n", "import subprocess\n", "import torch\n", "import tempfile\n", "from langdetect import detect\n", "from transformers import MarianMTModel, MarianTokenizer\n", "import re\n", "import boto3" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# import functions from functions file\n", "\n", "from functions_mm import handle_query, transcribe_audio_original, submit_question, polly_text_to_speech, translate, translate_and_speech, clear_inputs, voice_map, language_map, default_language, languages\n", "\n" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "# Load environment variables.\n", "load_dotenv()\n", "\n", "# Set the model name for our LLMs.\n", "OPENAI_MODEL = \"gpt-3.5-turbo\"\n", "# Store the API key in a variable.\n", "OPENAI_API_KEY = os.getenv(\"OPENAI_API_KEY\")" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Running on local URL: http://127.0.0.1:7860\n", "Running on public URL: https://d38cfed7bcd225f5fe.gradio.live\n", "\n", "This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "