alsett.com
  • Home
  • Regions
    • Americas
    • Asia
    • Europe
    • Australia
    • Africa
  • Industry
    • Business & Services
      • Hospitality and Tourism
      • Marketing and Media
      • Printing and Signage
      • Business Services
      • Retail and Ecommerce
      • Education and Training
      • Technology and IT
      • Sports and Fitness
      • Beauty and Fashion
      • Healthcare and Medical
      • Finance and Investment
      • Human Resources
      • Real Estate
      • Arts and Entertainment
    • Industrial & Infrastructure
      • Manufacturing and Industrial
      • Construction and Architecture
      • Aviation and Aerospace
      • Automotive and Mobility
      • Agriculture and Horticulture
      • Security and Defense
      • Energy and Environment
      • Transportation and Logistics
      • Food and Beverage
      • Government and Public Sector
      • Supply Chain and Operations
      • Pharma and Biotech
      • Home and Interior
      • Chemicals and Plastics
  • Event Types
    • Convention
    • Trade Show
    • Fair
    • Summit
    • Conference
    • Festival
    • Symposium
    • Congress
  • Calendar
    • 2024
      • Jul 2024
      • Aug 2024
      • Sep 2024
    • 2025
      • Jan 2025
      • Feb 2025
      • Jun 2025
      • Jul 2025
      • Aug 2025
      • Sep 2025
      • Oct 2025
      • Nov 2025
      • Dec 2025
    • 2026
      • Jan 2026
      • Feb 2026
      • Mar 2026
      • Apr 2026
      • May 2026
      • Jun 2026
      • Jul 2026
      • Aug 2026
      • Sep 2026
      • Oct 2026
      • Nov 2026
      • Dec 2026
    • 2027
      • Jan 2027
      • Feb 2027
      • Mar 2027
      • Apr 2027
      • May 2027
      • Jun 2027
      • Sep 2027
      • Oct 2027
    • 2028
      • Mar 2028
      • Apr 2028
      • May 2028
      • Jul 2028
      • Oct 2028
  • Login
  • Register
No Result
View All Result

No products in the cart.

alsett.com
No Result
View All Result
Home Uncategorized

One-Click Audio Transcription Script: Seamless Setup and Processing

Pezhman Akrami by Pezhman Akrami
December 29, 2025
in Uncategorized
Reading Time: 10 mins read
0 0
0
One-Click Audio Transcription Script: Seamless Setup and Processing
2.9k
SHARES
3k
VIEWS
Share on FacebookShare on Twitter

This updated one-click script simplifies audio transcription like never before. It checks for and installs Homebrew, Python, and FFmpeg automatically, ensures the necessary Python packages are installed, and processes MP4 or MP3 files into text effortlessly. With minimal setup and a user-friendly approach, this script converts your audio into transcripts with a single command. Save time, eliminate setup hassles, and streamline your transcription workflow today!

Improvements and Fixes:

1. Version Comparison for Python:

The comparison of Python versions using if [[ “$PYTHON_VERSION” < “3.9” ]] may not work as intended because version strings aren’t directly comparable. Use sort -V for proper version comparison:

if [[ $(echo -e “$PYTHON_VERSIONn3.9” | sort -V | head -n1) != “3.9” ]]; then

2. Python Package Installation:

Use python3 -m pip instead of pip3 for consistency, especially since pip may not always be installed globally:

python3 -m pip install –upgrade pip

python3 -m pip install ffmpeg-python git+https://github.com/openai/whisper.git torch torchvision torchaudio –index-url https://download.pytorch.org/whl/cpu

3. Error Handling:

Add error handling for critical commands (e.g., Homebrew, Python, FFmpeg installation). Use || exit 1 to terminate the script if a step fails.

4. Script Portability:

The script is Mac-specific due to Homebrew. If portability is a concern (e.g., Linux users), you can check for package managers like apt or yum.

5. Processing Files:

If the $VOICE_DIR contains non-audio files, the loop will still attempt to process them. Add a check for supported file extensions:

if [[ “$EXT” =~ ^(mp4|mp3|wav)$ ]]; then

6. Temporary WAV Files:

Ensure temporary WAV files created during MP4 conversion are cleaned up to avoid clutter:

trap ‘rm -f “$VOICE_DIR/$BASENAME.wav”‘ EXIT

7. Dependencies Check Before Processing:

Ensure all dependencies are installed successfully before processing files. This avoids starting the transcription process if something is missing.

8. Improve Logging:

Use clearer messages and a log file to debug issues if needed:

LOG_FILE=”$HOME/transcriber.log”

echo “Starting script…” | tee -a “$LOG_FILE”

Updated Script:

#!/bin/bash

# Define folders

VOICE_DIR=”$HOME/voice”

TRANSCRIPT_DIR=”$HOME/transcript”

# Create folders if they don’t exist

mkdir -p “$VOICE_DIR” “$TRANSCRIPT_DIR”

# Log file

LOG_FILE=”$HOME/transcriber.log”

echo “Starting script at $(date)” | tee -a “$LOG_FILE”

# Function to check and install Homebrew

check_homebrew() {

    if ! command -v brew &> /dev/null; then

        echo “Homebrew not found. Installing Homebrew…” | tee -a “$LOG_FILE”

        /bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)” || { echo “Homebrew installation failed!” | tee -a “$LOG_FILE”; exit 1; }

        echo “Homebrew installed successfully.” | tee -a “$LOG_FILE”

    else

        echo “Homebrew is already installed.” | tee -a “$LOG_FILE”

    fi

}

# Function to check Python installation

check_python() {

    if ! command -v python3 &> /dev/null; then

        echo “Python3 not found. Installing…” | tee -a “$LOG_FILE”

        brew install python || { echo “Python installation failed!” | tee -a “$LOG_FILE”; exit 1; }

    fi

    echo “Python3 found. Checking version…” | tee -a “$LOG_FILE”

    PYTHON_VERSION=$(python3 –version | awk ‘{print $2}’)

    if [[ $(echo -e “$PYTHON_VERSIONn3.9” | sort -V | head -n1) != “3.9” ]]; then

        echo “Python version is below 3.9. Updating…” | tee -a “$LOG_FILE”

        brew upgrade python || { echo “Python upgrade failed!” | tee -a “$LOG_FILE”; exit 1; }

    else

        echo “Python version is sufficient.” | tee -a “$LOG_FILE”

    fi

}

# Function to install required Python packages

install_dependencies() {

    echo “Installing required Python packages…” | tee -a “$LOG_FILE”

    python3 -m pip install –upgrade pip || { echo “Pip upgrade failed!” | tee -a “$LOG_FILE”; exit 1; }

    python3 -m pip install ffmpeg-python git+https://github.com/openai/whisper.git torch torchvision torchaudio –index-url https://download.pytorch.org/whl/cpu || { echo “Package installation failed!” | tee -a “$LOG_FILE”; exit 1; }

}

# Function to check FFmpeg installation

check_ffmpeg() {

    if ! command -v ffmpeg &> /dev/null; then

        echo “FFmpeg not found. Installing…” | tee -a “$LOG_FILE”

        brew install ffmpeg || { echo “FFmpeg installation failed!” | tee -a “$LOG_FILE”; exit 1; }

    else

        echo “FFmpeg is already installed.” | tee -a “$LOG_FILE”

    fi

}

# Check and install dependencies

echo “Checking dependencies…” | tee -a “$LOG_FILE”

check_homebrew

check_python

check_ffmpeg

install_dependencies

# Prompt user to place file in voice folder

echo “Place your MP4 or MP3 files in the folder: $VOICE_DIR” | tee -a “$LOG_FILE”

echo “Press Enter when you’re ready to proceed…” | tee -a “$LOG_FILE”

read

# Process files in voice folder

echo “Processing files…” | tee -a “$LOG_FILE”

for file in “$VOICE_DIR”/*; do

    if [[ -f “$file” ]]; then

        FILENAME=$(basename “$file”)

        BASENAME=”${FILENAME%.*}”

        EXT=”${FILENAME##*.}”

        if [[ “$EXT” =~ ^(mp4|mp3|wav)$ ]]; then

            # Convert MP4 to WAV if needed

            if [[ “$EXT” == “mp4” ]]; then

                echo “Converting $FILENAME to WAV…” | tee -a “$LOG_FILE”

                ffmpeg -i “$file” -ar 16000 -ac 1 -c:a pcm_s16le “$VOICE_DIR/$BASENAME.wav” || { echo “Conversion failed!” | tee -a “$LOG_FILE”; exit 1; }

                file=”$VOICE_DIR/$BASENAME.wav”

            fi

            # Run transcription using Whisper

            echo “Transcribing $FILENAME…” | tee -a “$LOG_FILE”

            python3 -m whisper “$file” –language fa –model small –output_dir “$TRANSCRIPT_DIR” || { echo “Transcription failed!” | tee -a “$LOG_FILE”; exit 1; }

            echo “Transcription completed for $FILENAME. Check the transcript folder: $TRANSCRIPT_DIR” | tee -a “$LOG_FILE”

        else

            echo “Skipping unsupported file: $FILENAME” | tee -a “$LOG_FILE”

        fi

    fi

done

echo “All tasks completed!” | tee -a “$LOG_FILE”

Key Enhancements:

1. Improved Python version comparison.

2. Error handling for critical steps.

3. Temporary file cleanup.

4. Support for only valid file types.

5. Logging for troubleshooting.

Let me know if you’d like further adjustments!

Tags: AI and Machine LearningTech & Ai
ShareTweetPin
Previous Post

One Wild Moment: A Tale of Unexpected Romance and Love

Next Post

Online Business Card Ordering | Order Cards Effortlessly

Please login to join discussion

Archives

Events

No Content Available

Covering the Global Expo

Alsett is the leading news platform for the global expo industry — covering trade shows, exhibitions, trends, data, companies, and event insights.

COMPANY

  • About
  • Contact
  • Careers
  • Industries
  • Regions
  • Insights
  • Service Providers

ADVERTISE

  • Advertise With Us
  • Media Kit
  • For Exhibitors
  • For Organizers
  • Submit Event News

RESOURCES

  • Privacy Policy
  • Terms of Service
  • Fact-Checking Policy
  • Corrections Policy
  • Editorial Guidelines
  • Editorial Team
  • Ethics & Transparency
  • Expo Max 360
  • American Expo Company
  • Expo Man
  • None Stop Expo

Welcome Back!

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Fill the forms below to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In
No Result
View All Result
  • Home
  • Regions
    • Americas
    • Asia
    • Europe
    • Australia
    • Africa
  • Industry
    • Business & Services
      • Hospitality and Tourism
      • Marketing and Media
      • Printing and Signage
      • Business Services
      • Retail and Ecommerce
      • Education and Training
      • Technology and IT
      • Sports and Fitness
      • Beauty and Fashion
      • Healthcare and Medical
      • Finance and Investment
      • Human Resources
      • Real Estate
      • Arts and Entertainment
    • Industrial & Infrastructure
      • Manufacturing and Industrial
      • Construction and Architecture
      • Aviation and Aerospace
      • Automotive and Mobility
      • Agriculture and Horticulture
      • Security and Defense
      • Energy and Environment
      • Transportation and Logistics
      • Food and Beverage
      • Government and Public Sector
      • Supply Chain and Operations
      • Pharma and Biotech
      • Home and Interior
      • Chemicals and Plastics
  • Event Types
    • Convention
    • Trade Show
    • Fair
    • Summit
    • Conference
    • Festival
    • Symposium
    • Congress
  • Calendar
    • 2024
      • Jul 2024
      • Aug 2024
      • Sep 2024
    • 2025
      • Jan 2025
      • Feb 2025
      • Jun 2025
      • Jul 2025
      • Aug 2025
      • Sep 2025
      • Oct 2025
      • Nov 2025
      • Dec 2025
    • 2026
      • Jan 2026
      • Feb 2026
      • Mar 2026
      • Apr 2026
      • May 2026
      • Jun 2026
      • Jul 2026
      • Aug 2026
      • Sep 2026
      • Oct 2026
      • Nov 2026
      • Dec 2026
    • 2027
      • Jan 2027
      • Feb 2027
      • Mar 2027
      • Apr 2027
      • May 2027
      • Jun 2027
      • Sep 2027
      • Oct 2027
    • 2028
      • Mar 2028
      • Apr 2028
      • May 2028
      • Jul 2028
      • Oct 2028
  • Login
  • Sign Up
  • Cart

© 2025 Alsett.com