changed dir structure and modified setup.py to use tatt package

This commit is contained in:
2019-02-12 19:45:11 -05:00
parent 9d0abce9fe
commit 8a8ac24c73
7 changed files with 10 additions and 121 deletions

View File

@@ -1,22 +0,0 @@
import os
from pathlib import Path
import sqlite3
STT_SERVICES = {
'amazon': {
'cost_per_minute': .024,
'free': '60_minutes_per_month_for_the_first_12_months',
},
}
AWS_BUCKET_NAME_FMTR_MEDIA = 'tatt-media-{}'
AWS_BUCKET_NAME_FMTR_TRANSCRIPT = 'tatt-transcript-{}'
AWS_CREDENTIALS_FILEPATH = (
os.getenv('AWS_CREDENTIALS_FILEPATH')
or Path.home() / '.aws/credentials'
)
AWS_REGION = 'us-east-1'
SERVICE_CLASS_NAME = 'transcribe'

View File

@@ -1,9 +0,0 @@
class ConfigError(Exception):
pass
class AlreadyExistsError(Exception):
pass

View File

@@ -1,77 +0,0 @@
import config
from tatt import vendors
def print_all_services(free_only=False, print_=True):
# TODO: make a jinja template for this
all_services_string = (
'\n\nHere are all the available ' +
f'{"free " if free_only else ""}speech-to-text services:' +
'\n\n' +
'\n'.join(['{}{}{}{}'.format('\t', service_name, '\t\t',
f'({info["free"].replace("_", " ")})'
if isinstance(info["free"], str) else ""
)
for service_name, info in
config.STT_SERVICES.items()])
+ '\n'
)
if print_:
print(all_services_string)
return all_services_string
def get_service(service_name):
return getattr(getattr(vendors, service_name), config.SERVICE_CLASS_NAME)
def print_transcription_jobs(jobs):
max_job_name_length = max(len(job['name'])
for job_list in jobs.values()
for job in job_list)
max_service_name_length = max(len(provider_name) for provider_name in jobs)
print()
print('Service',
'Job Name',
(max_job_name_length - len('Job Name')) * ' ',
' Status')
print('-------',
'--------',
(max_job_name_length - len('Job Name')) * ' ',
' ------')
for provider_name, job_list in jobs.items():
for job in job_list:
num_spaces_between = max_job_name_length - len(job['name'])
print(provider_name, job['name'], ' ' * num_spaces_between,
job['status'], sep=' ')
print()
def get_transcription_jobs(service_name=None, name=None, status=None):
all_jobs = {}
for stt_name, data in config.STT_SERVICES.items():
if service_name is None or service_name == stt_name:
jobs = get_service(stt_name).get_transcription_jobs(
job_name_query=name,
status=status)
if jobs:
all_jobs[stt_name] = jobs
return all_jobs
def get_transcription_jobs_dict():
jobs = get_transcription_jobs()
return {
job['name']: {
'service_name': service_name,
'status': job['status']
}
for service_name, job_list in jobs.items()
for job in job_list
}

View File

@@ -11,10 +11,10 @@ setup(
'boto3',
'requests',
],
dependency_links=['https://github.com/zevaverbach/tatt#egg=package-0.1'],
packages=find_packages(),
# dependency_links=['https://github.com/zevaverbach/tatt#egg=package-0.1'],
packages=['tatt'],
entry_points='''
[console_scripts]
transcribe=transcribe:cli
transcribe=tatt.transcribe:cli
''',
)

View File

@@ -1,6 +1,5 @@
import config
import vendors
from tatt import config
from tatt import vendors
def print_all_services(free_only=False, print_=True):

View File

@@ -5,9 +5,9 @@ import sys
import click
import config
import exceptions
import helpers
from tatt import config
from tatt import exceptions
from tatt import helpers
from tatt import vendors
@@ -87,5 +87,3 @@ def this(dry_run, media_filepath, service_name):
raise click.ClickException(str(e))
print(f'Okay, job {job_num} is being transcribed. Use "get" '
'command to download it.')

View File

@@ -6,8 +6,8 @@ import uuid
import boto3
import config
import exceptions
from tatt import config
from tatt import exceptions
NAME = 'amazon'
BUCKET_NAME_MEDIA = config.AWS_BUCKET_NAME_FMTR_MEDIA.format(NAME)