-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial package and basic functionality
- Loading branch information
1 parent
b0c345a
commit 276204b
Showing
5 changed files
with
109 additions
and
0 deletions.
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,5 @@ | ||
__ver_major__ = 0 | ||
__ver_minor__ = 1 | ||
__ver_patch__ = 0 | ||
__ver_tuple__ = (__ver_major__, __ver_minor__, __ver_patch__) | ||
__version__ = "%d.%d.%d" % __ver_tuple__ |
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,40 @@ | ||
import os | ||
import subprocess | ||
|
||
reaper_path = r'' | ||
|
||
data_directory = r'' | ||
|
||
output_directory = r'' | ||
|
||
def analyze_directory(data_directory, reaper_path = None, output_directory = None): | ||
if reaper_path is None: | ||
reaper_path = 'reaper' | ||
elif not os.path.exists(reaper_path): | ||
raise(OSError('Reaper binary was not found at \'{}\'.'.format(reaper_path))) | ||
|
||
if not os.path.exists(data_directory): | ||
raise(OSError('The data directory \'{}\' was not found.'.format(data_directory))) | ||
|
||
if output_directory is not None and not os.path.exists(output_directory): | ||
os.makedirs(output_directory) | ||
|
||
for root, dir, files in os.walk(data_directory): | ||
for f in files: | ||
if not f.lower().endswith('.wav'): | ||
continue | ||
wav_path = os.path.join(root, f) | ||
base_name = os.path.splitext(f)[0] | ||
if output_directory is None: | ||
output_path = os.path.join(root, base_name + '.f0') | ||
pm_path = os.path.join(root, base_name + '.pm') | ||
else: | ||
new_root = root.replace(data_directory, output_directory) | ||
if not os.path.exists(new_root): | ||
os.makedirs(new_root) | ||
output_path = os.path.join(new_root, base_name + '.f0') | ||
pm_path = os.path.join(new_root, base_name + '.pm') | ||
subprocess.call([reaper_path, '-i', wav_path, '-f', output_path, '-p', pm_path, '-a']) | ||
|
||
if __name__ == '__main__': | ||
main() |
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,2 @@ | ||
|
||
|
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,30 @@ | ||
|
||
|
||
import argparse | ||
|
||
from reaper.batch_reaper import analyze_directory | ||
|
||
def main(): | ||
|
||
#### Parse command-line arguments | ||
parser = argparse.ArgumentParser(description = \ | ||
'PyReaper: analyze directory') | ||
parser.add_argument('data_directory', help='Full path to wav files') | ||
parser.add_argument('-r', '--reaper_path', default = '', type=str, help='Path to reaper binary if not on path') | ||
parser.add_argument('-o', '--output_directory', default='', type=str, help='Directory to save output if not with the wav files') | ||
|
||
args = parser.parse_args() | ||
|
||
#### | ||
data = args.data_directory | ||
reaper = args.reaper_path | ||
if reaper == '': | ||
reaper = None | ||
output = args.output_directory | ||
if output == '': | ||
output = None | ||
analyze_directory(data, reaper, output) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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,32 @@ | ||
import sys | ||
from setuptools import setup | ||
|
||
import reaper | ||
|
||
def readme(): | ||
with open('README.md') as f: | ||
return f.read() | ||
|
||
|
||
setup(name='reaper', | ||
version=reaper.__version__, | ||
description='', | ||
long_description='', | ||
classifiers=[ | ||
'Development Status :: 3 - Alpha', | ||
'Programming Language :: Python', | ||
'Programming Language :: Python :: 3', | ||
'Operating System :: OS Independent', | ||
'Topic :: Scientific/Engineering', | ||
'Topic :: Text Processing :: Linguistic', | ||
], | ||
keywords='pitch google-reaper', | ||
url='https://github.com/SpeechInContext/pyReaper', | ||
author='Michael McAuliffe', | ||
author_email='[email protected]', | ||
packages=['reaper', | ||
'reaper.command_line'], | ||
entry_points = { | ||
'console_scripts': ['batch_reaper=reaper.command_line.batch_reaper:main',], | ||
} | ||
) |