Skip to content

colindevwork/macOS-Dictation-Fix-External-Mic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Automating killall corespeechd Every 3 Hours on macOS

Basically, it is a fix for macOS Dictation not working with external microphones (USB mics, AirPods, etc.) by automatically terminating corespeechd by running killall corespeechd every 3 hours in the background using LaunchAgents in macOS.

Easiest Way to Set Up

1. Download and Run the Script

The easiest way to automate this process is by running the provided setup script.

Steps:

  1. Download the script or create it manually by saving the following as setup_kill_corespeechd.sh:

    #!/bin/bash
    
    # Define the LaunchAgent path
    PLIST_PATH="$HOME/Library/LaunchAgents/com.user.killcorespeechd.plist"
    
    # Create the LaunchAgents directory if it doesn't exist
    mkdir -p "$HOME/Library/LaunchAgents"
    
    # Write the plist file
    cat <<EOF > "$PLIST_PATH"
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>Label</key>
        <string>com.user.killcorespeechd</string>
    
        <key>ProgramArguments</key>
        <array>
            <string>/usr/bin/killall</string>
            <string>corespeechd</string>
        </array>
    
        <key>StartInterval</key>
        <integer>10800</integer> <!-- 3 hours in seconds -->
    
        <key>RunAtLoad</key>
        <true/>
    </dict>
    </plist>
    EOF
    
    # Load the LaunchAgent
    launchctl load "$PLIST_PATH"
    
    # Enable the LaunchAgent for persistence across reboots
    launchctl enable user/$(id -u)/com.user.killcorespeechd
    
    # Check status
    launchctl list | grep com.user.killcorespeechd && echo "Service successfully installed and running." || echo "Failed to start service."
    
    echo "Setup complete. The corespeechd process will be terminated every 3 hours."
  2. Make the script executable

    chmod +x setup_kill_corespeechd.sh
  3. Run the script

    ./setup_kill_corespeechd.sh

Manual Setup Instructions

1. Create a LaunchAgent Property List (.plist) File

Run the following command to create and open a .plist file:

mkdir -p ~/Library/LaunchAgents
nano ~/Library/LaunchAgents/com.user.killcorespeechd.plist

2. Add the Following Content to the File

Copy and paste the following XML into the file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.user.killcorespeechd</string>

    <key>ProgramArguments</key>
    <array>
        <string>/usr/bin/killall</string>
        <string>corespeechd</string>
    </array>

    <key>StartInterval</key>
    <integer>10800</integer> <!-- 3 hours in seconds -->

    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>
  • StartInterval is set to 10,800 seconds (3 hours).
  • RunAtLoad ensures it runs immediately upon loading.

3. Load the LaunchAgent

Save the file and run:

launchctl load ~/Library/LaunchAgents/com.user.killcorespeechd.plist

4. Ensure It Runs on Startup

To make sure it persists across reboots, use:

launchctl enable user/$(id -u)/com.user.killcorespeechd

5. Check the Status

Verify that it’s running with:

launchctl list | grep com.user.killcorespeechd

6. Unload If Needed

If you ever need to stop it, run:

launchctl unload ~/Library/LaunchAgents/com.user.killcorespeechd.plist

Alternative: Using cron

If you prefer using cron, add the following line to your crontab (crontab -e):

0 */3 * * * /usr/bin/killall corespeechd

This will execute the command every 3 hours.


Notes

  • LaunchAgents is preferred for macOS since cron has been deprecated in favor of launchd.
  • If you encounter issues, check logs using:
    log stream --predicate 'subsystem == "com.apple.launchservicesd"'

Let me know if you have any questions! 🚀

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages