Skip to content

Commit

Permalink
Initial package and basic functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcauliffe committed Jul 22, 2015
1 parent b0c345a commit 276204b
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 0 deletions.
5 changes: 5 additions & 0 deletions reaper/__init__.py
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__
40 changes: 40 additions & 0 deletions reaper/batch_reaper.py
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()
2 changes: 2 additions & 0 deletions reaper/command_line/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@


30 changes: 30 additions & 0 deletions reaper/command_line/batch_reaper.py
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()
32 changes: 32 additions & 0 deletions setup.py
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',],
}
)

0 comments on commit 276204b

Please sign in to comment.