From f9c03e460d413f3adcae299b2c2fce2937eac5f6 Mon Sep 17 00:00:00 2001 From: evrrn Date: Fri, 25 Feb 2022 08:51:01 +0000 Subject: [PATCH] Update examples --- examples.ipynb | 77 ---------------------------------------------- examples_tts.ipynb | 4 +-- 2 files changed, 2 insertions(+), 79 deletions(-) mode change 100644 => 100755 examples.ipynb mode change 100644 => 100755 examples_tts.ipynb diff --git a/examples.ipynb b/examples.ipynb old mode 100644 new mode 100755 index 9b1c5c8..5e37c94 --- a/examples.ipynb +++ b/examples.ipynb @@ -486,83 +486,6 @@ "decoded = decoder(torch.Tensor(ort_outs[0])[0])\n", "print(decoded)" ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "0omBCDk5ZfBd" - }, - "source": [ - "# TensorFlow Example" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "cellView": "form", - "id": "BmoBJY7QnC6P" - }, - "outputs": [], - "source": [ - "#@title Install and Import Dependencies\n", - "\n", - "# this assumes that you have a relevant version of PyTorch installed\n", - "!pip install -q torchaudio omegaconf intel-tensorflow" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "BzTdtvQ-okUC" - }, - "source": [ - "## Minimal example" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "lnmXz_jyE8G7" - }, - "outputs": [], - "source": [ - "import os\n", - "import torch\n", - "import subprocess\n", - "import tensorflow as tf\n", - "import tensorflow_hub as tf_hub\n", - "from omegaconf import OmegaConf\n", - "\n", - "language = 'en' # also available 'de', 'es'\n", - "\n", - "# load provided utils using torch.hub for brevity\n", - "_, decoder, utils = torch.hub.load(repo_or_dir='snakers4/silero-models', model='silero_stt', language=language)\n", - "(read_batch, split_into_batches,\n", - " read_audio, prepare_model_input) = utils\n", - "\n", - " # see available models\n", - "torch.hub.download_url_to_file('https://raw.githubusercontent.com/snakers4/silero-models/master/models.yml', 'models.yml')\n", - "models = OmegaConf.load('models.yml')\n", - "available_languages = list(models.stt_models.keys())\n", - "assert language in available_languages\n", - "\n", - "# load the actual tf model\n", - "torch.hub.download_url_to_file(models.stt_models.en.latest.tf, 'tf_model.tar.gz')\n", - "subprocess.run('rm -rf tf_model && mkdir tf_model && tar xzfv tf_model.tar.gz -C tf_model', shell=True, check=True)\n", - "tf_model = tf.saved_model.load('tf_model')\n", - "\n", - "# download a single file, any format compatible with TorchAudio\n", - "torch.hub.download_url_to_file('https://opus-codec.org/static/examples/samples/speech_orig.wav', dst ='speech_orig.wav', progress=True)\n", - "test_files = ['speech_orig.wav']\n", - "batches = split_into_batches(test_files, batch_size=10)\n", - "input = prepare_model_input(read_batch(batches[0]))\n", - "\n", - "# tf inference\n", - "res = tf_model.signatures[\"serving_default\"](tf.constant(input.numpy()))['output_0']\n", - "print(decoder(torch.Tensor(res.numpy())[0]))" - ] } ], "metadata": { diff --git a/examples_tts.ipynb b/examples_tts.ipynb old mode 100644 new mode 100755 index 2f5a74e..bfcd587 --- a/examples_tts.ipynb +++ b/examples_tts.ipynb @@ -345,7 +345,7 @@ "source": [ "#@title Install dependencies\n", "\n", - "!pip install -q torch==1.9" + "!pip install -q torch==1.10" ] }, { @@ -514,7 +514,7 @@ " local_file)\n", "\n", "if not os.path.isfile('tts_utils.py'):\n", - " torch.hub.download_url_to_file('https://raw.githubusercontent.com/snakers4/silero-models/master/tts_utils.py',\n", + " torch.hub.download_url_to_file('https://raw.githubusercontent.com/snakers4/silero-models/master/src/tts_utils.py',\n", " 'tts_utils.py')\n", " from tts_utils import apply_tts # modify these utils and use them your project\n", " \n",