0

I have a bit of experience in web development, Javascript & its most popular frameworks, but I'm a huge noob in Python and "offline" development.

I'm trying to create this sound recorder script for Windows that would essentially record all day (for surveillance purposes in an office) and output 10 minutes files in a sequential manner.

While these files are outputted (so the main process is running), after a certain number of files have been created I would like to convert them into another format (initial files are very big).

I've managed to create the program for recording continously. I know how to convert them into another format as well. My problem is: when the time comes to convert some of the files into another format, how can I do this without interrupting the main process of this recorder? (meaning, not stop the main purpose of continously recording sound).

I'm sure it has something to do with concurrent / parallel programming but I'm not sure where to start or how to integrate those concepts in my code.. A sort of shortcut I've been thinking about is to just create 2 separate scripts (one for recording and the other for the conversion) and deploy them both as Windows processes but that doesn't seem as the most elegant solution for this problem. I'm not even sure if it would work, but my limited knowledge tells me that Windows will operate them at the same time so that would solve my issue.

But can it be done in one single Python file? What subset of Python programming should I learn to find out how to achieve this kind of task?

I'm really lost and tried to research it myself but everything on this topic is very overwhelming for me as a beginner and doesn't seem related to my problem.

user3666197
  • 1
  • 6
  • 50
  • 92
Armand Felix
  • 43
  • 1
  • 6
  • Have you heard about multithreading? – mkrieger1 Feb 14 '22 at 08:20
  • Heard about it, not sure how to implement it though. Can it be done without any additional modules, in a single Python file? I'll look into it further. – Armand Felix Feb 14 '22 at 09:51
  • @ArmandFelix Yes, you can do it all in a single file. Look at the examples from [this RealPython article](https://realpython.com/intro-to-python-threading/), or if you are already familiar with how it works, just go read the [`threading` lib docs](https://docs.python.org/3/library/threading.html). – Lenormju Feb 14 '22 at 15:51
  • @Lenormju Wow thank you so much! That's really helpful, especially the first link. I'll go through it asap. – Armand Felix Feb 14 '22 at 17:00
  • @ArmandFelix I honestly think that it is a really good ressource for Python programming : detailed and comprehensible content, many topics covered, ... I also recommend their article on [**concurrency**](https://realpython.com/python-concurrency/) which covers the different flavors : **threading**, **multiprocessing**, and **async**, their advantages and drawbacks, and introductory examples. – Lenormju Feb 15 '22 at 09:22

0 Answers0