Quantcast
Viewing all articles
Browse latest Browse all 4867

Python • Python Code Issue

I have some python code for my sound recorder and I am using the audacity script-mod-pipe. I have some python but it's 2 projects. (1 for recording and 1 for stopping.) My goal is to record the audio when the code is running but when it stops it should stop recording but it doesn't it keeps recording. Any idea on how to fix this?
Here's My Code:

Code:

import sysimport osimport sysif sys.platform == 'win32':    print("pipe-test.py, running on windows")    TONAME = '\\\\.\\pipe\\ToSrvPipe'    FROMNAME = '\\\\.\\pipe\\FromSrvPipe'    EOL = '\r\n\0'else:    print("pipe-test.py, running on linux or mac")    TONAME = '/tmp/audacity_script_pipe.to.' + str(os.getuid())    FROMNAME = '/tmp/audacity_script_pipe.from.' + str(os.getuid())    EOL = '\n'print("Write to  \"" + TONAME +"\"")if not os.path.exists(TONAME):    print(" ..does not exist.  Ensure Audacity is running with mod-script-pipe.")    sys.exit()print("Read from \"" + FROMNAME +"\"")if not os.path.exists(FROMNAME):    print(" ..does not exist.  Ensure Audacity is running with mod-script-pipe.")    sys.exit()print("-- Both pipes exist.  This is a good thing.")TOFILE = open(TONAME, 'w')print("-- File to which to write has been opened")FROMFILE = open(FROMNAME, 'rt')print("-- File from which to read has now been opened also\r\n")def send_command(command):    """Send a single command."""    print("Send: >>> \n"+command)    TOFILE.write(command + EOL)    TOFILE.flush()send_command("Record1stChoice")#Record command ^import sysimport osimport sysif sys.platform == 'win32':    print("pipe-test.py, running on windows")    TONAME = '\\\\.\\pipe\\ToSrvPipe'    FROMNAME = '\\\\.\\pipe\\FromSrvPipe'    EOL = '\r\n\0'else:    print("pipe-test.py, running on linux or mac")    TONAME = '/tmp/audacity_script_pipe.to.' + str(os.getuid())    FROMNAME = '/tmp/audacity_script_pipe.from.' + str(os.getuid())    EOL = '\n'print("Write to  \"" + TONAME +"\"")if not os.path.exists(TONAME):    print(" ..does not exist.  Ensure Audacity is running with mod-script-pipe.")    sys.exit()print("Read from \"" + FROMNAME +"\"")if not os.path.exists(FROMNAME):    print(" ..does not exist.  Ensure Audacity is running with mod-script-pipe.")    sys.exit()print("-- Both pipes exist.  This is a good thing.")TOFILE = open(TONAME, 'w')print("-- File to which to write has been opened")FROMFILE = open(FROMNAME, 'rt')print("-- File from which to read has now been opened also\r\n")def send_command(command):    """Send a single command."""    print("Send: >>> \n"+command)    TOFILE.write(command + EOL)    TOFILE.flush()send_command("Stop")#Stop recording command ^
As you can see it's 2 projects. How can I merge them together?

Statistics: Posted by Henrik Gill — Sun Feb 25, 2024 6:30 pm



Viewing all articles
Browse latest Browse all 4867

Trending Articles