{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "a2cd4050", "metadata": {}, "outputs": [], "source": [ "from transcribe import transcribe" ] }, { "cell_type": "code", "execution_count": 2, "id": "24e1d24e", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Help on function transcribe in module transcribe:\n", "\n", "transcribe(path, file_type, model=None, language=None, verbose=True)\n", " Implementation of OpenAI's whisper model. Downloads model, transcribes audio files in a folder and returns the text files with transcriptions\n", "\n" ] } ], "source": [ "help(transcribe)" ] }, { "cell_type": "code", "execution_count": 3, "id": "e52477fb", "metadata": {}, "outputs": [], "source": [ "path='sample_audio/'#folder path\n", "file_type='ogg' #check your file for file type, will only transcribe those files\n", "model='medium' #'small', 'medium', 'large' (tradeoff between speed and accuracy)\n", "language= None #tries to auto-detect, other options include 'English', 'Spanish', etc...\n", "verbose = True # prints output while transcribing, False to deactivate" ] }, { "cell_type": "code", "execution_count": 4, "id": "d66866af", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Using medium model, you can change this by specifying model=\"medium\" for example\n", "Only looking for file type ogg, you can change this by specifying file_type=\"mp3\"\n", "Expecting None language, you can change this by specifying language=\"English\". None will try to auto-detect\n", "Verbosity is True. If TRUE it will print out the text as it is transcribed, you can turn this off by setting verbose=False\n", "\n", "There are 2 ogg files in path: sample_audio/\n", "\n", "\n", "Loading model...\n", "Transcribing file number number 1: Armstrong_Small_Step\n", "Model and file loaded...\n", "Starting transcription...\n", "\n", "Detecting language using up to the first 30 seconds. Use `--language` to specify the language\n", "Detected language: English\n", "[00:00.000 --> 00:24.000] That's one small step for man, one giant leap for mankind.\n", "\n", "Finished file number 1.\n", "\n", "\n", "\n", "Transcribing file number number 2: Axel_Pettersson_röstinspelning\n", "Model and file loaded...\n", "Starting transcription...\n", "\n", "Detecting language using up to the first 30 seconds. Use `--language` to specify the language\n", "Detected language: Swedish\n", "[00:00.000 --> 00:16.000] Hej, jag heter Axel Pettersson, jag föddes i Örebro 1976. Jag har varit Wikipedia sen 2008 och jag har översatt röstintroduktionsprojektet till svenska.\n", "\n", "Finished file number 2.\n", "\n", "\n", "\n" ] }, { "data": { "text/plain": [ "'Finished transcription, files can be found in sample_audio/transcriptions'" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "transcribe(path, file_type, model, language, verbose)" ] }, { "cell_type": "code", "execution_count": null, "id": "0bc67265", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.4" } }, "nbformat": 4, "nbformat_minor": 5 }