-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b27cad4
commit 38ec8a6
Showing
8 changed files
with
157 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
\FirstTry\app\ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# -*- mode: python ; coding: utf-8 -*- | ||
|
||
block_cipher = None | ||
|
||
|
||
a = Analysis(['text_logger.py'], | ||
pathex=['C:\\Users\\qtckp\\OneDrive\\Рабочий стол\\SpeechLogger\\FirstTry'], | ||
binaries=[], | ||
datas=[], | ||
hiddenimports=[], | ||
hookspath=[], | ||
runtime_hooks=[], | ||
excludes=[], | ||
win_no_prefer_redirects=False, | ||
win_private_assemblies=False, | ||
cipher=block_cipher, | ||
noarchive=False) | ||
pyz = PYZ(a.pure, a.zipped_data, | ||
cipher=block_cipher) | ||
exe = EXE(pyz, | ||
a.scripts, | ||
[], | ||
exclude_binaries=True, | ||
name='text_logger', | ||
debug=False, | ||
bootloader_ignore_signals=False, | ||
strip=False, | ||
upx=True, | ||
console=True ) | ||
coll = COLLECT(exe, | ||
a.binaries, | ||
a.zipfiles, | ||
a.datas, | ||
strip=False, | ||
upx=True, | ||
upx_exclude=[], | ||
name='text_logger') |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Thu May 21 22:31:00 2020 | ||
@author: qtckp | ||
""" | ||
|
||
|
||
import pyaudio | ||
|
||
# detect devices: | ||
p = pyaudio.PyAudio() | ||
host_info = p.get_host_api_info_by_index(0) | ||
device_count = host_info.get('deviceCount') | ||
devices = [] | ||
|
||
# iterate between devices: | ||
for i in range(0, device_count): | ||
device = p.get_device_info_by_host_api_device_index(0, i) | ||
devices.append(device['name']) | ||
|
||
print(devices) | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Thu May 21 23:15:43 2020 | ||
@author: qtckp | ||
https://pypi.org/project/SoundCard/ | ||
""" | ||
|
||
|
||
import soundcard as sc | ||
|
||
|
||
# get a list of all speakers: | ||
speakers = sc.all_speakers() | ||
# get the current default speaker on your system: | ||
default_speaker = sc.default_speaker() | ||
# get a list of all microphones: | ||
mics = sc.all_microphones() | ||
# get the current default microphone on your system: | ||
default_mic = sc.default_microphone() | ||
|
||
|
||
import numpy | ||
|
||
# record and play back one second of audio: | ||
data = default_mic.record(samplerate=48000, numframes=48000) | ||
default_speaker.play(data/numpy.max(data), samplerate=48000) | ||
|
||
|
||
# alternatively, get a `Recorder` and `Player` object | ||
# and play or record continuously: | ||
with default_mic.recorder(samplerate=48000) as mic, default_speaker.player(samplerate=48000) as sp: | ||
for _ in range(100): | ||
data = mic.record(numframes=1024) | ||
sp.play(data) | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Thu May 21 22:13:51 2020 | ||
@author: qtckp | ||
https://stackoverflow.com/questions/26573556/record-speakers-output-with-pyaudio | ||
""" | ||
|
||
|
||
"""PyAudio example: Record a few seconds of audio and save to a WAVE file.""" | ||
|
||
import pyaudio | ||
import wave | ||
|
||
CHUNK = 1024 | ||
FORMAT = pyaudio.paInt16 | ||
CHANNELS = 2 | ||
RATE = 44100 | ||
RECORD_SECONDS = 5 | ||
WAVE_OUTPUT_FILENAME = "output.wav" | ||
|
||
p = pyaudio.PyAudio() | ||
|
||
stream = p.open(format=FORMAT, | ||
channels=CHANNELS, | ||
rate=RATE, | ||
input=True, | ||
frames_per_buffer=CHUNK) | ||
|
||
print("* recording") | ||
|
||
frames = [] | ||
|
||
for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)): | ||
data = stream.read(CHUNK) | ||
frames.append(data) | ||
|
||
print("* done recording") | ||
|
||
stream.stop_stream() | ||
stream.close() | ||
p.terminate() | ||
|
||
wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb') | ||
wf.setnchannels(CHANNELS) | ||
wf.setsampwidth(p.get_sample_size(FORMAT)) | ||
wf.setframerate(RATE) | ||
wf.writeframes(b''.join(frames)) | ||
wf.close() |