From 2769ddf68b7a02d2f9d354b4408fed8f00e1d1ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristofer=20S=C3=B6derstr=C3=B6m?= Date: Fri, 14 Apr 2023 10:31:26 +0200 Subject: [PATCH] dedicated windows and mac scripts, fixed verbose checkbox --- CITATION.cff | 2 +- GUI.py | 1 + Mac_2_instructions.txt | 6 ++++++ README.md | 7 +++---- run_Mac_1.sh | 4 ++++ run_Mac_2.command | 3 +++ run_Windows.bat | 5 +++++ run_gui.bat | 5 ----- sample_audio/transcriptions/Armstrong_Small_Step.txt | 4 +++- .../Axel_Pettersson_röstinspelning.txt | 3 ++- transcribe.py | 12 ++++++------ 11 files changed, 34 insertions(+), 18 deletions(-) create mode 100644 Mac_2_instructions.txt create mode 100644 run_Mac_1.sh create mode 100644 run_Mac_2.command create mode 100644 run_Windows.bat delete mode 100644 run_gui.bat diff --git a/CITATION.cff b/CITATION.cff index 1643ea5..8b0ad6e 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -5,7 +5,7 @@ authors: given-names: "Kristofer Rolf" orcid: "https://orcid.org/0000-0002-5322-3350" title: "transcribe" -version: 1.0 +version: 1.1.0 doi: 10.5281/zenodo.7760511 date-released: 2023-03-22 url: "https://github.com/soderstromkr/transcribe" diff --git a/GUI.py b/GUI.py index 3ccdf01..79ac5bf 100644 --- a/GUI.py +++ b/GUI.py @@ -14,6 +14,7 @@ class App: self.master = master master.title("Local Transcribe") + #style options style = ttk.Style() style.configure('TLabel', font=('Arial', 10), padding=10) style.configure('TEntry', font=('Arial', 10), padding=10) diff --git a/Mac_2_instructions.txt b/Mac_2_instructions.txt new file mode 100644 index 0000000..376591f --- /dev/null +++ b/Mac_2_instructions.txt @@ -0,0 +1,6 @@ +### Steps to make command file executable +To make a file executable on a Mac, you need to open a terminal window in the directory where the file is located. Then run the following command: + +chmod +x run_MAC_2.command + +After running this command, the file should be marked as executable and you should be able to run it by double-clicking on it. \ No newline at end of file diff --git a/README.md b/README.md index 44e6c09..011d681 100644 --- a/README.md +++ b/README.md @@ -31,13 +31,12 @@ git clone https://github.com/soderstromkr/transcribe.git ``` and use the example.ipynb template to use the script. **OR** download the ```transcribe.py``` file into your work folder. Then you can either import it to another script or notebook for use. I recommend jupyter notebook for new users, see the example below. (Remember to have transcribe.py and example.ipynb in the same working folder). -##### Example with jupyter notebook +#### Example with jupyter notebook See [example](example.ipynb) for an implementation on jupyter notebook, also added an example for a simple [workaround](example_no_internet.ipynb) to transcribe while offline. -##### Using the GUI +#### Using the GUI You can also run the GUI version from your terminal running ```python GUI.py``` or with the batch file called run_gui.bat, just make sure to add your conda path to it. If you want to download a model first, and then go offline for transcription, I recommend running the model with the default sample folder, which will download the model locally. The GUI should look like this: ![python GUI.py](gui_jpeg.jpg?raw=true) -##### Model location -On Windows, the models are located in ```C:\Users\\. cache\whisper\``` + [^1]: Advanced users can use ```pip install ffmpeg-python``` but be ready to deal with some [PATH issues](https://stackoverflow.com/questions/65836756/python-ffmpeg-wont-accept-path-why), which I encountered in Windows 11. diff --git a/run_Mac_1.sh b/run_Mac_1.sh new file mode 100644 index 0000000..f251c65 --- /dev/null +++ b/run_Mac_1.sh @@ -0,0 +1,4 @@ +#!/bin/bash +echo Starting... +conda activate venv +python -u GUI.py diff --git a/run_Mac_2.command b/run_Mac_2.command new file mode 100644 index 0000000..54a376e --- /dev/null +++ b/run_Mac_2.command @@ -0,0 +1,3 @@ +#!/bin/bash +echo Running Script +python -u GUI.py diff --git a/run_Windows.bat b/run_Windows.bat new file mode 100644 index 0000000..62025da --- /dev/null +++ b/run_Windows.bat @@ -0,0 +1,5 @@ +@echo off +echo Starting... +call conda activate venv +REM OPTION 2 : (KEEP TEXT WITHIN QUOTES AND CHANGE USERNAME) "C:/Users/user/Anaconda3/condabin/activate.bat" +call python GUI.py \ No newline at end of file diff --git a/run_gui.bat b/run_gui.bat deleted file mode 100644 index 86c45cf..0000000 --- a/run_gui.bat +++ /dev/null @@ -1,5 +0,0 @@ -@echo off -call 'PATH_TO_CONDA' -call 'ACTIVATE_NEEDED_ENVS' -call python GUI.py -PAUSE \ No newline at end of file diff --git a/sample_audio/transcriptions/Armstrong_Small_Step.txt b/sample_audio/transcriptions/Armstrong_Small_Step.txt index 8a460c9..8bdc6b8 100644 --- a/sample_audio/transcriptions/Armstrong_Small_Step.txt +++ b/sample_audio/transcriptions/Armstrong_Small_Step.txt @@ -1,3 +1,5 @@ Armstrong_Small_Step In seconds: -[0.00 --> 24.00]: That's one small step for man, one giant leap for mankind. \ No newline at end of file +[0.00 --> 7.00]: I'm going to step off the limb now. +[7.00 --> 18.00]: That's one small step for man. +[18.00 --> 24.00]: One giant leap for mankind. \ No newline at end of file diff --git a/sample_audio/transcriptions/Axel_Pettersson_röstinspelning.txt b/sample_audio/transcriptions/Axel_Pettersson_röstinspelning.txt index 653ba62..ad17e5f 100644 --- a/sample_audio/transcriptions/Axel_Pettersson_röstinspelning.txt +++ b/sample_audio/transcriptions/Axel_Pettersson_röstinspelning.txt @@ -1,3 +1,4 @@ Axel_Pettersson_röstinspelning In seconds: -[0.00 --> 16.00]: 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. \ No newline at end of file +[0.00 --> 6.14]: Hej, jag heter Axel Pettersson. Jag följer bror 1976. +[6.40 --> 15.10]: Jag har varit vikerpedjan sen 2008 och jag har översatt röstintroduktionsprojektet till svenska. \ No newline at end of file diff --git a/transcribe.py b/transcribe.py index 703b951..d5db6cb 100644 --- a/transcribe.py +++ b/transcribe.py @@ -1,7 +1,7 @@ import whisper import glob, os -def transcribe(path, file_type, model=None, language=None, verbose=True): +def transcribe(path, file_type, model=None, language=None, verbose=False): '''Implementation of OpenAI's whisper model. Downloads model, transcribes audio files in a folder and returns the text files with transcriptions''' try: @@ -11,10 +11,10 @@ def transcribe(path, file_type, model=None, language=None, verbose=True): glob_file = glob.glob(path+'/*{}'.format(file_type)) - print('Using {} model, you can change this by specifying model="medium" for example'.format(model)) - print('Only looking for file type {}, you can change this by specifying file_type="mp3"'.format(file_type)) - print('Expecting {} language, you can change this by specifying language="English". None will try to auto-detect'.format(language)) - print('Verbosity is {}. If TRUE it will print out the text as it is transcribed, you can turn this off by setting verbose=False'.format(verbose)) + print('Using {} model'.format(model)) + print('File type is {}'.format(file_type)) + print('Language is being detected automatically for each file') + print('Verbosity is set to {}'.format(verbose)) print('\nThere are {} {} files in path: {}\n\n'.format(len(glob_file), file_type, path)) print('Loading model...') @@ -28,7 +28,7 @@ def transcribe(path, file_type, model=None, language=None, verbose=True): result = model.transcribe( file, language=language, - verbose=True + verbose=verbose ) start=[] end=[]