Giter VIP home page Giter VIP logo

voicerecording's Introduction

VoiceRecording

This program records audio from the default input device, allowing the user to pause, resume, or exit the recording using specific key presses. It then saves the recorded audio to a file with a timestamp.

This is how it works

Check Administrator Privileges: The script checks if it is running with administrator privileges using os.geteuid(). If not, it prints a message and exits.

Import Libraries: Various libraries are imported to handle sound recording, file writing, threading, keyboard input, and time manipulation. Define Recording Function: The record_audio function handles audio recording. It reads audio data from the input device in chunks and appends it to a buffer.

Get Input Device Information: The default input device is identified, and its capabilities (such as the maximum number of input channels) are queried.

Set Parameters: Parameters like sample rate, number of channels, and chunk size are set.

Initialize Variables: Buffer and flags for controlling recording (pause and exit) are initialized.

User Input for Recording Time: The user is asked to input the recording time in seconds.

Start Recording Thread: The record_audio function is started in a separate thread, allowing parallel execution with the main program.

Monitor Keypresses: A loop monitors for keypresses to control recording: Spacebar: Toggles pause and resume. Esc key: Exits the recording.

Control Timing: time.sleep is used to control the timing of the recording chunks, synchronizing with the sample rate.

Stop Recording: The recording thread is joined, ensuring all audio data is captured.

Compile Recorded Data and Save: The recorded audio data in the buffer is compiled into a single array. The current date and time are formatted into a string. The recording is saved to a file named output_.wav.

Print Completion Message: A completion message is printed to the console, confirming the successful recording and filename. This script integrates various functionalities to provide a flexible audio recording tool, allowing the user to control the recording process interactively. It demonstrates a combination of threading, sound processing, and user interaction in Python.

voicerecording's People

Contributors

mwrosslee avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.