示例#1
0
def gen_protoc_complier():
    cur_dir = os.path.dirname(__file__)
    template_name = "protoc_compiler_template.py"
    with open(os.path.join(cur_dir, template_name)) as fd:
        template_py = fd.read()

    target_name = os.path.join(cur_dir, "protoc-gen-python_grpc")
    with open(target_name, "w") as fd:
        content = "#!%s\n" % sys.executable + template_py
        fd.write(content)
    chmod(target_name, 0o755)
    os.environ["PATH"] = cur_dir + os.pathsep + os.environ["PATH"]
示例#2
0
def mkrealdir(name):
    st = posix.stat(name)  # Get the mode
    mode = S_IMODE(st[ST_MODE])
    linkto = posix.readlink(name)
    files = posix.listdir(name)
    posix.unlink(name)
    posix.mkdir(name, mode)
    posix.chmod(name, mode)
    linkto = cat('..', linkto)
    #
    for file in files:
        if file not in ('.', '..'):
            posix.symlink(cat(linkto, file), cat(name, file))
示例#3
0
def mkrealfile(name):
    st = posix.stat(name)  # Get the mode
    mode = S_IMODE(st[ST_MODE])
    linkto = posix.readlink(name)  # Make sure again it's a symlink
    f_in = open(name, 'r')  # This ensures it's a file
    posix.unlink(name)
    f_out = open(name, 'w')
    while 1:
        buf = f_in.read(BUFSIZE)
        if not buf: break
        f_out.write(buf)
    del f_out  # Flush data to disk before changing mode
    posix.chmod(name, mode)
示例#4
0
def mkrealdir(name):
       st = posix.stat(name) # Get the mode
       mode = S_IMODE(st[ST_MODE])
       linkto = posix.readlink(name)
       files = posix.listdir(name)
       posix.unlink(name)
       posix.mkdir(name, mode)
       posix.chmod(name, mode)
       linkto = cat('..', linkto)
       #
       for file in files:
               if file not in ('.', '..'):
                       posix.symlink(cat(linkto, file), cat(name, file))
示例#5
0
def mkrealfile(name):
       st = posix.stat(name) # Get the mode
       mode = S_IMODE(st[ST_MODE])
       linkto = posix.readlink(name) # Make sure again it's a symlink
       f_in = open(name, 'r') # This ensures it's a file
       posix.unlink(name)
       f_out = open(name, 'w')
       while 1:
               buf = f_in.read(BUFSIZE)
               if not buf: break
               f_out.write(buf)
       del f_out # Flush data to disk before changing mode
       posix.chmod(name, mode)
    def 訓練(cls, 訓練資料夾, 頻率, 顯示訓練過程=True,
           SPTK執行檔路徑=安裝HTS語音辨識程式.sptk執行檔目錄(),
           HTS執行檔路徑=安裝HTS語音辨識程式.hts執行檔目錄(),
           htsDemo目錄=安裝HTS語音辨識程式.htsDemo目錄()):
        if (
            not isdir(join(訓練資料夾, 'data', 'raw')) or
            not isdir(join(訓練資料夾, 'data', 'labels', 'mono')) or
            not isdir(join(訓練資料夾, 'data', 'labels', 'full')) or
            not isdir(join(訓練資料夾, 'data', 'questions'))
        ):
            raise 參數錯誤(
                '訓練資料夾的data內底有欠資料!!'
                '請看臺灣言語工具的文件'
            )

        cls._扣demo的資料到訓練資料夾(htsDemo目錄, 訓練資料夾)

        '走HTS'
        with cls._換目錄(訓練資料夾):
            音框長度 = 頻率 // 40
            音框移動 = 音框長度 // 5
    #         if 頻率 < 20000:
    #             參數量 = 24
    #         else:
    #             參數量 = 40
            # 'GAMMA=3 LNGAIN=1 MGCORDER={參數量}'
            chmod('./configure', S_IRUSR | S_IWUSR | S_IXUSR)
            HTS設定指令 = [
                './configure',
                '--with-sptk-search-path={}'.format(SPTK執行檔路徑),
                '--with-hts-search-path={}'.format(HTS執行檔路徑),
                'LOWERF0=60',
                'UPPERF0=500',
                'USEGV=0',
                'SAMPFREQ={}'.format(頻率),
                'FRAMELEN={}' .format(音框長度),
                'FRAMESHIFT={}'.format(音框移動),
            ]
            cls._走指令(HTS設定指令, env={'LANG': 'C'}, 愛直接顯示輸出=顯示訓練過程)
            HTS走指令 = ['make', 'all']
            cls._走指令(HTS走指令, env={'LANG': 'C'}, 愛直接顯示輸出=顯示訓練過程)
        return join(訓練資料夾, 'voices', 'qst001', 'ver1', 'ver1.htsvoice')
示例#7
0
    def 訓練(cls,
           訓練資料夾,
           頻率,
           顯示訓練過程=True,
           SPTK執行檔路徑=安裝HTS語音辨識程式.sptk執行檔目錄(),
           HTS執行檔路徑=安裝HTS語音辨識程式.hts執行檔目錄(),
           htsDemo目錄=安裝HTS語音辨識程式.htsDemo目錄()):
        if (not isdir(join(訓練資料夾, 'data', 'raw'))
                or not isdir(join(訓練資料夾, 'data', 'labels', 'mono'))
                or not isdir(join(訓練資料夾, 'data', 'labels', 'full'))
                or not isdir(join(訓練資料夾, 'data', 'questions'))):
            raise 參數錯誤('訓練資料夾的data內底有欠資料!!' '請看臺灣言語工具的文件')

        cls._扣demo的資料到訓練資料夾(htsDemo目錄, 訓練資料夾)

        '走HTS'
        with cls._換目錄(訓練資料夾):
            音框長度 = 頻率 // 40
            音框移動 = 音框長度 // 5
            #         if 頻率 < 20000:
            #             參數量 = 24
            #         else:
            #             參數量 = 40
            # 'GAMMA=3 LNGAIN=1 MGCORDER={參數量}'
            chmod('./configure', S_IRUSR | S_IWUSR | S_IXUSR)
            HTS設定指令 = [
                './configure',
                '--with-sptk-search-path={}'.format(SPTK執行檔路徑),
                '--with-hts-search-path={}'.format(HTS執行檔路徑),
                'LOWERF0=60',
                'UPPERF0=500',
                'USEGV=0',
                'SAMPFREQ={}'.format(頻率),
                'FRAMELEN={}'.format(音框長度),
                'FRAMESHIFT={}'.format(音框移動),
            ]
            cls._走指令(HTS設定指令, env={'LANG': 'C'}, 愛直接顯示輸出=顯示訓練過程)
            HTS走指令 = ['make', 'all']
            cls._走指令(HTS走指令, env={'LANG': 'C'}, 愛直接顯示輸出=顯示訓練過程)
        return join(訓練資料夾, 'voices', 'qst001', 'ver1', 'ver1.htsvoice')
示例#8
0
def copystat(src, dst):
    st = posix.stat(src)
    mode = divmod(st[0], MODEBITS)[1]
    posix.chmod(dst, mode)
    posix.utimes(dst, st[7:9])
示例#9
0
def copymode(src, dst):
    st = posix.stat(src)
    mode = divmod(st[0], MODEBITS)[1]
    posix.chmod(dst, mode)
示例#10
0
def copystat(src, dst):
       st = posix.stat(src)
       mode = divmod(st[0], MODEBITS)[1]
       posix.chmod(dst, mode)
       posix.utimes(dst, st[7:9])
示例#11
0
def copymode(src, dst):
       st = posix.stat(src)
       mode = divmod(st[0], MODEBITS)[1]
       posix.chmod(dst, mode)