diff --git a/README.md b/README.md index 5333ecbf..6f07e453 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,8 @@ More information on contributing and the general code of conduct for discussion | Text to Image | [Text to Image](https://github.com/DhanushNehru/Python-Scripts/tree/main/Text%20to%20Image) | A Python script that will take your text and convert it to a JPEG. | | Thread Progress | [Thread Progress](https://github.com/DhanushNehru/Python-Scripts/tree/main/Thread%20Progress) | A Python script demonstrating safe multithreading by using a lock to update a shared progress variable concurrently. | | Tic Tac Toe 1 | [Tic Tac Toe 1](https://github.com/DhanushNehru/Python-Scripts/tree/main/Tic-Tac-Toe%201) | A game of Tic Tac Toe. | -| Tik Tac Toe 2 | [Tik Tac Toe 2](https://github.com/DhanushNehru/Python-Scripts/tree/main/Tic-Tac-Toe%202) | A game of Tik Tac Toe. | +| Tik Tac Toe 2 | [Tik Tac Toe 2](https://github.com/DhanushNehru/Python-Scripts/tree/main/Tic-Tac-Toe%202) | A game of Tik Tac Toe. +| Transcribing | [Transcribing](https://github.com/DhanushNehru/Python-Scripts/tree/main/Transcribing) | Python code to transcribe any audio file. | | Turtle Art & Patterns | [Turtle Art](https://github.com/DhanushNehru/Python-Scripts/tree/main/Turtle%20Art) | Scripts to view turtle art also have prompt-based ones. | | Turtle Graphics | [Turtle Graphics](https://github.com/DhanushNehru/Python-Scripts/tree/main/Turtle%20Graphics) | Code using turtle graphics. | | Twitter Selenium Bot | [Twitter Selenium Bot](https://github.com/DhanushNehru/Python-Scripts/tree/main/Twitter%20Selenium%20Bot) | A bot that can interact with Twitter in a variety of ways. | diff --git a/Transcribing/call.mp3 b/Transcribing/call.mp3 new file mode 100644 index 00000000..f6165ebc Binary files /dev/null and b/Transcribing/call.mp3 differ diff --git a/Transcribing/call_transcript.txt b/Transcribing/call_transcript.txt new file mode 100644 index 00000000..264a5455 --- /dev/null +++ b/Transcribing/call_transcript.txt @@ -0,0 +1,60 @@ + Hi, thank you for calling Witten Brothers of Richmond. + I'm Kerry, how may I direct your call? + Service. + Okay, would you like to schedule a service appointment? + Speak to Representative. + Perfect. Can I have your first and last name please? + Michelle Harris. + Thank you. + Let me connect you with one of our service advisors. Please hold. + Hello. + Hello. + Michelle Harris is on the line meeting assistant for service. + Can I connect you to the caller? + Yes. + Thank you for calling and having me here today. + Hi, Gabi. I was calling in regards to getting some service done on a 2004 key. + And my question is, there is a couple of recalls on the G. So how does that work? + How does recalls work as far as bringing the vehicle in? + Can we just have the appointment? + Can I get the last idea then? + Yes, four in a second. + For an account. + It's near a meet of an X-ray. Simply take your required order to the nearest + inelvate in the scene center for immediate assistance. + You don't need to schedule an appointment if you have an X in order. + For a list of locations, visit inelvate.org. + Fast and again. + Good. + The last date. + I heard four, four, three, eight, zero, three, zero, seven. + Okay, you're here for now. Right now, we're about three. + And about three, seven. + We'll close that. + So I'm actually not saying eight has been recalculated from the vehicle. + Okay, so if we might pull it up and I go into a different side. + It's saying in one of the... + I want to say yes, let me go to the actual. + So it's the actual sensor that is saying that it is... + So, the vehicles have been specific and on this bin that you gave me. + There's no open recall. + Your vehicle might have fallen within a range of... + Zins will have the recaliment for for your specific vehicle that does not fly. + Yeah, because I put in the bin number, because that's what it asked me to either say, + the license plate or the van and a print shaft position sensor was what had popped up. + Okay, so how do we get this fixed as far as... + If I'm putting in a bin number and you're putting in the bin number, + how do we get that fixed if it is... + Is what I'm seeing say something. + I mean, is something going on with your vehicle? + Because I... + From the name Bachelor, that's what I have. + Because we are a de-lister. + You don't have a recall. + But if something's going on with your vehicle, we can get it in the vehicle. + Look at it. + It's what the... + 19888 I don't know. + Okay. + Okay, thank you. + You're welcome. diff --git a/Transcribing/readme.md b/Transcribing/readme.md new file mode 100644 index 00000000..150acce7 --- /dev/null +++ b/Transcribing/readme.md @@ -0,0 +1,74 @@ +# MUST READ BEFORE EXECUTION (ONE TIME ONLY) + +This script allows you to **transcribe audio files (MP3, WAV, etc.) to text** using the **Faster Whisper** Python library. Please read these instructions carefully before running the script. + +--- + +## 1️⃣ Prerequisites + +1. **Install Python (3.8 or higher)** + Download and install from [https://www.python.org/downloads/](https://www.python.org/downloads/). + Make sure to **add Python to your system PATH** during installation. + OR you can simply run this command in terminal to install python: "winget install Python.Python.3" + for MAC: brew install python + +2. **Install ffmpeg** (required for audio decoding) + - **Windows:** [https://ffmpeg.org/download.html](https://ffmpeg.org/download.html) + - **Linux:** `sudo apt install ffmpeg` + - **Mac:** `brew install ffmpeg` + Make sure ffmpeg is **added to your system PATH** so the script can find it. (Explanation in End on how to do this) + Now you can verify if both are installed by writing "python --version" or "py --version" and "ffmpeg -version" +--- + +## 2️⃣ Audio File Requirements + +- Place the audio file you want to transcribe **in the same folder** as the script. +- Make sure to use the **correct file extension** (e.g., `.mp3`, `.wav`). +- Also works for videos (.mp4) +- The output transcription will also be saved in the same folder with the filename: + + +--- + +## 3️⃣ Choosing the Model + +The script supports the following **Faster Whisper models**. Please choose the one that fits your needs: + +| Model | Speed & Size | Accuracy | +|---------|------------------------------|-------------------------------| +| tiny | Fastest, smallest | Least accurate | +| small | Fast, small | Slightly more accurate | +| base | Moderate speed & size | Good accuracy | +| medium | Slower, larger | More accurate | +| large | Slowest, largest | Most accurate | + +**Tip:** Use `base` for a good balance between speed and accuracy. Model names are **case-insensitive**. + +--- + +## 4️⃣ Running the Script + +1. Open a terminal or command prompt in the folder containing the script. +2. Run the script: type "python transcription.py" +3. Follow Along the input instructions prompted on screen + +## 5 Setting ffmpeg in Your System PATH + +To make ffmpeg accessible to the script: + +**Windows:** +1. Download and unzip ffmpeg. +2. Copy the path to the `bin` folder (e.g., `C:\ffmpeg\bin`). +3. Open **Environment Variables → Path → Edit → New**, paste the path, and click **OK**. +4. Restart the terminal or command prompt. + +**Linux / Mac:** +write export PATH=$PATH:/path/to/ffmpeg/bin + +## Developer +- GitHub: https://github.com/Syed-56 +- LinkedIn: https://www.linkedin.com/in/syedsultan10 + +## Dependencies & Licenses +- Faster Whisper: MIT License (https://github.com/guillaumekln/faster-whisper) +- ffmpeg: LGPL/GPL License (https://ffmpeg.org) \ No newline at end of file diff --git a/Transcribing/transcription.py b/Transcribing/transcription.py new file mode 100644 index 00000000..db3c2c21 --- /dev/null +++ b/Transcribing/transcription.py @@ -0,0 +1,60 @@ +import sys +import subprocess +import shutil + +#functions to install python packages +def installPackage(pkgName): + print(f"[INFO] {pkgName} not found. Installing...") + subprocess.check_call([sys.executable, "-m", "pip", "install", pkgName]) + print(f"[INFO] {pkgName} installed successfully!") + +try: + from faster_whisper import WhisperModel +except ImportError: + installPackage("faster_whisper") + from faster_whisper import WhisperModel + +# Check for ffmpeg +if shutil.which("ffmpeg") is None: + print( + "[ERROR] ffmpeg not found on your system.\n" + "Please install ffmpeg to use this script:\n" + "- Windows: https://ffmpeg.org/download.html\n" + "- Linux: sudo apt install ffmpeg\n" + "- Mac: brew install ffmpeg" + ) + sys.exit(1) + +print("[INFO] All dependencies are ready!") + +import os +while True: + audio_file = input("Enter the name of or path to your audio file (MP3, WAV, MP4 etc.): ").strip() + if not os.path.isfile(audio_file): + print(f"[ERROR] File '{audio_file}' does not exist. Please check the path and try again.") + else: + break +valid_models = ["tiny", "small", "base", "medium", "large"] +print("Models (Sorted from Fastest-Smallest-Least Accurate To Slowest-Largest-Most Accurate):-\n") +print(valid_models) + +while True: + model_size = input("\nEnter the model size: ").strip().lower() + + if model_size not in valid_models: + print(f"[ERROR] Invalid model size '{model_size}'. Please choose from {valid_models}.\n") + else: + break + +model = WhisperModel(model_size) + +output_file = audio_file.rsplit(".", 1)[0] + "_transcript.txt" +segments, info = model.transcribe(audio_file) + +with open(output_file, "w", encoding="utf-8") as f: + print("\nTranscribing.") + for segment in segments: + print(".", end="", flush=True) + f.write(segment.text + "\n") +print(f"\n[INFO] Transcription saved to {output_file}") +print("\n -- Scripted by Syed Sultan (github = Syed-56)") \ No newline at end of file