Elevenlabs API를 사용한 AI TT
먼저 필요한 라이브러리를 설치해야합니다. 다음 명령으로 PIP를 사용하여 설치할 수 있습니다 : pip3 install -r requirements.txt
고립 된 환경 (권장)의 경우 다음을 사용하여 가상 환경을 생성하고 활성화하십시오.
python3 -m venv venv
source venv/bin/activate # On Linux/macOS
venvScriptsactivate # On Windows
pip3 install -r requirements.txt
프로그램을 사용하려면 ElevenLabs API 키를 제공해야합니다. 여기에 등록하여 API 키를 얻을 수 있습니다. API 키를 얻은 후에는 elevenlabs_api_key라는 환경 변수로 설정해야합니다.
다음 단계에 따라 ElevenLabs_api_key 환경 변수를 지속적으로 설정하십시오 (권장).
Linux 또는 MacOS :
.zshrc 파일을여십시오. 예를 들어 : nano ~/.zshrcexport ELEVENLABS_API_KEY=your_api_key_hereyour_api_key_here 실제 API 키로 교체하십시오.source ~/.zshrc 실행하여 변경 사항을로드하십시오.Windows에서 :
ELEVENLABS_API_KEY 입력하고 변수 값에 대한 실제 API 키를 입력하십시오.또는 다음과 같이 현재 세션에 대해서만 ElevenLabs_api_key 환경 변수를 일시적으로 설정할 수 있습니다.
Linux 또는 MacOS :
export ELEVENLABS_API_KEY=your_api_key_hereyour_api_key_here 실제 API 키로 교체하십시오.Windows에서 :
setx ELEVENLABS_API_KEY "your_api_key_here"your_api_key_here 실제 API 키로 교체하십시오.elevenlabs_api_key 환경 변수가 설정되면 아래 사용 섹션에 설명 된대로 프로그램을 실행할 수 있습니다.
TTS.py [-h] (-a | -s | --get-voices) [-v VOICE_ID]
[-t TEXT | -f FILE | -u URL | --ai | --gear | --business | --culture | --science | --security]
[-m MODEL] [-o OUTPUT]
-h, --help show this help message and exit
-a, --audio Use /v1/text-to-speech API endpoint
-s, --stream Use /v1/text-to-speech/{voice_id}/stream API endpoint
--get-voices Retrieve the available voices
-v VOICE_ID, --voice-id VOICE_ID Voice ID to use for the conversion
-t TEXT, --text TEXT Text to convert to speech
-f FILE, --file FILE Text file to convert to speech
-u URL, --url URL BETA: URL of article to convert to speech
--ai Read the latest AI news
--gear Read the latest gear news
--business Read the latest business news
--culture Read the latest culture news
--science Read the latest science news
--security Read the latest security news
-m MODEL, --model MODEL ElevenLabs model to use
-o OUTPUT, --output OUTPUT Output to a .wav file
pninz6obpgdqgcfmajgb 음성 ID를 사용하여 input.txt의 텍스트를 음성으로 변환하려면 다음 명령을 실행하십시오.
python3 TTS.py -a -f input.txt --voice-id pNInz6obpgDQGcFmaJgB
문자열을 직접 입력하여 음성으로 변환합니다.
python3 TTS.py -a --text "This is an example block of text"
최신 AI 뉴스를 가져와 텍스트 to Speech를 사용하여 읽으려면 다음 명령 중 하나를 실행하십시오.
기본 이름 Audio.wav로 오디오 파일을 생성하려면 :
python3 TTS.py -a --AI
사용자 정의 이름으로 오디오 파일을 생성하려면 다음과 같습니다.
python3 TTS.py -a --AI -o AI_news.wav
오디오 만 스트리밍하려면 :
python3 TTS.py -s --AI