Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions gentle/standard_kaldi.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
class Kaldi:
def __init__(self, nnet_dir=None, hclg_path=None, proto_langdir=None):
devnull = open(os.devnull, 'w')

cmd = [EXECUTABLE_PATH]

if nnet_dir is not None:
cmd.append(nnet_dir)
cmd.append(hclg_path)
Expand All @@ -26,7 +26,7 @@ def _cmd(self, c):
def push_chunk(self, buf):
# Wait until we're ready
self._cmd("push-chunk")

cnt = len(buf)/2
self._cmd(str(cnt))
self._p.stdin.write(buf) #arr.tostring())
Expand Down Expand Up @@ -73,12 +73,12 @@ def __del__(self):
import sys

infile = sys.argv[1]

k = Kaldi()

buf = numm3.sound2np(infile, nchannels=1, R=8000)
print 'loaded_buf', len(buf)

idx=0
while idx < len(buf):
k.push_chunk(buf[idx:idx+160000].tostring())
Expand Down
6 changes: 2 additions & 4 deletions gentle/transcriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def __init__(self, kaldi_queue, chunk_len=20, overlap_t=2, nthreads=4):
self.chunk_len = chunk_len
self.overlap_t = overlap_t
self.nthreads = nthreads

self.kaldi_queue = kaldi_queue

def transcribe(self, wavfile, progress_cb=None):
Expand Down Expand Up @@ -41,11 +41,10 @@ def transcribe_chunk(idx):
progress_cb({"message": ' '.join([X['word'] for X in ret]),
"percent": len(chunks) / float(n_chunks)})


pool = Pool(min(n_chunks, self.nthreads))
pool.map(transcribe_chunk, range(n_chunks))
pool.close()

chunks.sort(key=lambda x: x['start'])

# Combine chunks
Expand Down Expand Up @@ -99,7 +98,6 @@ def transcribe_chunk(idx):

resources = gentle.Resources()


k_queue = Queue()
for i in range(3):
k_queue.put(standard_kaldi.Kaldi(resources.nnet_gpu_path, resources.full_hclg_path, resources.proto_langdir))
Expand Down
9 changes: 6 additions & 3 deletions gentle/util/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@

class SourceResolver:
def __init__(self):
self.project_root = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, os.pardir))
root = os.environ.get(ENV_VAR)
if root:
self.project_root = root
else:
self.project_root = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, os.pardir))

def get_binary(self, name):
path_in_project = os.path.join(self.project_root, name)
Expand All @@ -18,8 +22,7 @@ def get_binary(self, name):
return name

def get_resource(self, name):
root = os.environ.get(ENV_VAR) or self.project_root
return os.path.join(root, name)
return os.path.join(self.project_root, name)

def get_datadir(self, name):
return self.get_resource(name)
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from setuptools import setup
from setuptools import setup, find_packages
from gentle import __version__

setup(
Expand All @@ -14,6 +14,6 @@
url='http://lowerquality.com/gentle',
author='Robert M Ochshorn',
license='MIT',
packages=['gentle'],
packages=find_packages(),
install_requires=['twisted'],
)