1667815444
이 기사에서는 Python을 사용하여 음성 녹음기를 만드는 방법을 안내합니다. Python 프로그래밍 언어를 사용하여 음성 녹음기를 만들려면 Python에서 sounddevice 라이브러리를 사용해야 합니다.
pip install sounddevice
sounddevice 라이브러리는 음성을 녹음하는 데 도움이 되지만 특정 파일 형식으로 음성을 저장 하려면 pip 명령을 사용하여 설치할 수 있는 Python 의 SciPy 라이브러리 를 사용해야 합니다 .
pip install SciPy
import sounddevice
from scipy.io.wavfile import write
def voice_recorder(seconds, file):
print("Recording Started…")
recording = sounddevice.rec((seconds * 44100), samplerate= 44100, channels=2)
sounddevice.wait()
write(file, 44100, recording)
print("Recording Finished")
voice_recorder(10, "record.wav")
위의 코드에서는 녹음 파일을 기록하고 저장하는 Python 함수를 정의했습니다. 두 개의 매개변수가 필요합니다.
위의 코드를 실행하면 녹음이 시작되었다는 메시지가 표시되고 입력한 시간(초) 후에 녹음이 완료되었음을 표시합니다. 완료되면 Python 파일이 있는 동일한 디렉토리에 자동으로 저장됩니다.
1667815444
이 기사에서는 Python을 사용하여 음성 녹음기를 만드는 방법을 안내합니다. Python 프로그래밍 언어를 사용하여 음성 녹음기를 만들려면 Python에서 sounddevice 라이브러리를 사용해야 합니다.
pip install sounddevice
sounddevice 라이브러리는 음성을 녹음하는 데 도움이 되지만 특정 파일 형식으로 음성을 저장 하려면 pip 명령을 사용하여 설치할 수 있는 Python 의 SciPy 라이브러리 를 사용해야 합니다 .
pip install SciPy
import sounddevice
from scipy.io.wavfile import write
def voice_recorder(seconds, file):
print("Recording Started…")
recording = sounddevice.rec((seconds * 44100), samplerate= 44100, channels=2)
sounddevice.wait()
write(file, 44100, recording)
print("Recording Finished")
voice_recorder(10, "record.wav")
위의 코드에서는 녹음 파일을 기록하고 저장하는 Python 함수를 정의했습니다. 두 개의 매개변수가 필요합니다.
위의 코드를 실행하면 녹음이 시작되었다는 메시지가 표시되고 입력한 시간(초) 후에 녹음이 완료되었음을 표시합니다. 완료되면 Python 파일이 있는 동일한 디렉토리에 자동으로 저장됩니다.
1668418166
이 튜토리얼에서는 Python을 사용하여 음성 녹음기를 만드는 방법을 배웁니다. Python 프로그래밍 언어를 사용하여 음성 녹음기를 만들려면 Python에서 sounddevice 라이브러리를 사용해야 합니다. 이전에 이 라이브러리를 사용한 적이 없다면 아래에 언급된 pip 명령을 사용하여 쉽게 설치할 수 있습니다.
pip install sounddevice
sounddevice 라이브러리는 음성을 녹음하는 데 도움이 되지만 특정 파일 형식으로 음성을 저장 하려면 pip 명령을 사용하여 설치할 수 있는 Python 의 SciPy 라이브러리 를 사용해야 합니다 .
pip install SciPy
이제 아래는 코드 예제와 함께 Python을 사용하여 음성 녹음기를 만드는 방법입니다.
import sounddevice
from scipy.io.wavfile import write
def voice_recorder(seconds, file):
print("Recording Started…")
recording = sounddevice.rec((seconds * 44100), samplerate= 44100, channels=2)
sounddevice.wait()
write(file, 44100, recording)
print("Recording Finished")
voice_recorder(10, "record.wav")
위의 코드를 실행하면 녹음이 시작되었다는 메시지가 표시되고 입력한 시간(초) 후에 녹음이 완료되었음을 표시합니다. 완료되면 Python 파일이 있는 동일한 디렉토리에 자동으로 저장됩니다.
1657102812
Python은 다양한 작업을 수행할 수 있는 널리 사용되는 범용 언어입니다. 그 중 하나는 디스플레이 화면을 기록하는 것입니다. 즉, pyautogui 모듈을 사용하여 화면 레코더를 만드는 것입니다. 아래 첨부된 것은 이 기능의 간단한 데모입니다.
이 자습서에서는 PyCharm에서 Python 을 사용하여 스크린 레코더 를 빌드하는 방법을 배웁니다.
먼저 PyCharm을 열고 Screen_Recorder 라는 프로젝트를 만듭니다. 그런 다음 터미널 을 열고 아래 나열된 명령을 입력하여 해당 라이브러리를 설치합니다.
pip install opencv-python
pip install numpy
pip install pyautogui
pip install pywin32
그런 다음 이 프로젝트의 main.py 파일 내에 아래 지정된 코드 를 입력합니다. 코드에 대한 설명은 코드 주석을 참조하십시오.
# Import necessary libraries:
import cv2
import numpy as np
import pyautogui
from win32api import GetSystemMetrics
import time
# Access screen width:
w = GetSystemMetrics(0)
# Access screen height:
h = GetSystemMetrics(1)
# Store screen dimensions within a tuple:
dimension = (w, h)
# Define codec -> FourCC is a 4-byte code used to specify the video codec
fourcc = cv2.VideoWriter_fourcc(*"XVID")
# VideoWriter -> This class provides C++ API for writing video files or image sequences
# Constructor parameters-> video filename, video codec, video frame-rate(fps), screen dimensions
output = cv2.VideoWriter("recording.mp4", fourcc, 20.0, dimension)
# Access current system time:
now = time.time()
# Read screen recording duration via user input:
# time() -> Returns the time as a floating point number expressed in seconds
duration = int(input('Specify recording duration in seconds: '))
# Buffer time to ensure that the recorded video duration is as specified by user:
# This is done because, code must be executed up till line #33, prior to recording initiation.
duration += duration
# Identify the time at which recording must stop:
end_time = now + duration
while True:
# Take a screenshot:
# screenshot() -> Returns an Image object
img = pyautogui.screenshot()
# Import image data into NumPy array:
frame = np.array(img)
# Use cvtColor() method to convert image from BGR to RGB color format:
# This conversion ensures that the recording exactly resembles the content that had been recorded
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
# Write the frame into the file 'recording.mp4':
output.write(frame)
# Access current system time:
current_time = time.time()
# Check if it is time to stop recording. If so, break out of while loop.
if current_time>end_time:
break
# Release the capture
output.release()
코드가 실행되고 사용자가 원하는 비디오 지속 시간을 입력하면 녹화가 시작됩니다. 녹음이 완료되고 mp4 파일이 생성되면 코드 실행이 종료됩니다.
1667913384
이 기사에서는 Python을 사용하여 나이 계산기를 만드는 방법에 대한 자습서를 소개합니다. 나이 계산기를 만들려면 두 개의 날짜가 필요합니다.
Python을 사용하여 나이 계산기를 만드는 방법은 다음과 같습니다.
def ageCalculator(y, m, d):
import datetime
today = datetime.datetime.now().date()
dob = datetime.date(y, m, d)
age = int((today-dob).days / 365.25)
print(age)
ageCalculator(1998, 9, 3)
위의 코드에서:
1669366395
이 튜토리얼에서는 Python을 사용하여 이력서 스캐너를 만드는 방법을 배웁니다. Python으로 이력서 스캐너를 만들려면 먼저 resume-parser라는 Python 모듈을 설치합니다. 이전에 이 모듈을 사용한 적이 없다면 pip 명령을 사용하여 쉽게 설치할 수 있습니다.
pip install resume-parser
이제 Python을 사용하여 이력서를 스캔하는 방법을 살펴보겠습니다.
def scan_resume(resume):
from resume_parser import resumeparse
data = resumeparse.read_file(resume)
for i, j in data.items():
print(f"{i}:>>{j}")
scan_resume("Jacks Thomas.docx")
산출:
email:>>support@codequsdev.com
phone:>>6896******
total_exp:>>2
university:>>['Lancaster University']
designition:>>['data scientist', 'quality assurance', 'machine learning']
degree:>>['BCom']
skills:>>['interpersonal skills', 'data science', 'facebook', 'email', 'sentiment analysis', 'tutorials', 'pressure', 'shopping', 'it', 'budget management', 'online', 'research', 'finance',]
이것은 Python 프로그래밍 언어를 사용하여 이력서를 쉽게 스캔하는 방법입니다.