Downloads audio files from wiki

This commit is contained in:
Dave Niewinski 2022-12-06 18:45:44 -05:00
commit f833bb99ce
4 changed files with 55 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.wav

14
README.md Normal file
View File

@ -0,0 +1,14 @@
GLaDOS RIVA
===========
This package will download audio for training data, then train a riva TTS network
Install
-------
pip3 install -r requirements.txt
Usage
-----
./download_audio.py

38
download_audio.py Executable file
View File

@ -0,0 +1,38 @@
#!/usr/bin/env python3
import requests
from tqdm import tqdm
import shutil
import os
blocklist = ["potato", "_ding_"]
audio_dir = 'audio'
if os.path.exists(audio_dir):
print("Deleting previously downloaded audio")
shutil.rmtree(audio_dir)
os.mkdir(audio_dir)
r = requests.get("https://theportalwiki.com/wiki/GLaDOS_voice_lines")
split_text = r.text.split()
urls = []
for chunk in split_text:
if "https:" in chunk and ".wav" in chunk:
url = chunk.replace('"', '').replace("href=", '')
if url not in urls:
for s in blocklist:
if s in url:
break
else:
urls.append(url)
print("Found " + str(len(urls)) + " urls")
for url in tqdm(urls):
filename = url[url.rindex("/")+1:]
response = requests.get(url)
open(os.path.join(audio_dir, filename), "wb").write(response.content)

2
requirements.txt Normal file
View File

@ -0,0 +1,2 @@
requests
tqdm