aboutsummaryrefslogtreecommitdiffstats
path: root/solo-tool-project/src/solo_tool/recorder.py
diff options
context:
space:
mode:
Diffstat (limited to 'solo-tool-project/src/solo_tool/recorder.py')
-rw-r--r--solo-tool-project/src/solo_tool/recorder.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/solo-tool-project/src/solo_tool/recorder.py b/solo-tool-project/src/solo_tool/recorder.py
index 71c8ac8..c628832 100644
--- a/solo-tool-project/src/solo_tool/recorder.py
+++ b/solo-tool-project/src/solo_tool/recorder.py
@@ -3,6 +3,8 @@ from pathlib import Path
import pyaudio as pa
from pydub import AudioSegment, effects
+from solo_tool.utils import getAudioDeviceIndex
+
class Recording:
def __init__(self, frames: list, channels: int, samplingRate: int, sampleFormat: int):
self._segment = AudioSegment(
@@ -23,9 +25,10 @@ class Recording:
self._segment.export(str(file), format="mp3", bitrate="320k")
class Recorder:
- def __init__(self, bufferSize: int, samplingRate: int):
+ def __init__(self, bufferSize: int, samplingRate: int, deviceName: str):
self._bufferSize = bufferSize
self._samplingRate = samplingRate
+ self._deviceName = deviceName
self._sampleFormat = pa.paInt16
self._channels = 2
self._pa = pa.PyAudio()
@@ -56,6 +59,7 @@ class Recorder:
rate=self._samplingRate,
frames_per_buffer=self._bufferSize,
input=True,
+ input_device_index=getAudioDeviceIndex(self._deviceName, self._pa),
stream_callback=self._callback)
def stopRecording(self) -> Recording: