Skip to main content

Python3 module for UTAU and singing-voice-database

Project description

utaupy

PyPI

UTAU周辺のデータ処理を行うPythonのパッケージです。READMEは書いてる途中です。
PythonでUTAUプラグインを作りたい場合は、C# 用の utauPlugin をPythonに移植した pyUtau のほうがいいかもしれません。ビブラートやピッチの扱いが便利そうです。

利用規約

LICENSE ファイルをご覧ください。

処理できるファイル

  • .ust (UTAU)
  • .txt (UTAU Plugin Script)
  • .txt (録音リスト)
  • .ini (setParam および UTAU音源原音設定)
  • .lab (歌唱データベース用音素ラベル)
  • .table (ローマ字かな対応表)
  • .svp (Synthesizer V R2)
  • .csv (REAPER リージョン・マーカー用)

機能概要

  • INI, UST, LAB ファイルのデータをクラスオブジェクトとして扱います。
  • INI, UST, LAB ファイルを変換できます。ただし不可逆の処理が多いです。

Methods


utaupy.ust

load(path)

USTファイルを読み取り、Ust オブジェクトにする。

ust = load(ust)  # type(ust): <utaupy.ust.Ust class object>

notenum_as_abc

音階番号を C4 とかの音階表記に変換する。国際表記に準拠。

notenum = 61
s = notenum_as_abc(notenum)
print(s)  # C4

Ust(collections.UserList)

UST ファイルを取り扱うための class

__init__

パラメータを格納する list self._notes を作成する。

def __init__(self):
"""インスタンス作成"""
# ノート(クラスオブジェクト)からなるリスト
self._notes = []

__len__

len(self) したときに Version, Setting, PREV, NEXT, TRACKEND を含む、UST内の全エントリ数を返す。

n = len(ust)  # type(n): int

write

Ust オブジェクトをファイル出力にする。出力した文字列を返す

ust.write(path)  # type(path): str
# return strings written in ustfile

property: notes

音符と休符の情報をリストで取得または登録する。

# Getter
l = ust.notes  # l: [Note, Note, Note, ..., Note] <list of utaupy.ust.Note objects>
# Setter
ust.notes = l  # l: [Note, Note, Note, ..., Note] <list of utaupy.ust.Note objects>

property: tempo

トラックのグローバルテンポを取得する。

# Getter
x = ust.tempo  # x: float
# Setter
ust.tempo = x  # x: float

reload_tempo

self._notes 内の全 Note にローカルテンポ取得用のパラメータ _alternative_tempo を設定する。

self.values や self.values の setter を使うと自動的にで実行される。

ust.reload_tempo()
# no return

reload_tag_number

全ノートのエントリ番号(タグ)を振りなおす。ファイル出力時に実行することを想定。

ust.reload_tag_number()
# no return

property: replace_lyrics(str old_lyric, str new_lyric)

全ノートの歌詞を置換する。

ust.replace_lyrics('か', 'か強')
# no return

vcv2cv

全ノートの連続音エイリアスを単独音にする。(空白で区切った後半をエイリアスにする)

make_finalnote_R

最後のノートが休符になるようにする。

ust.make_finalenote_R()
# no return

Note(collections.UserDict)

__init__

パラメータを格納する dict self.__d 、エントリを識別するタグ self.tag 、歌詞を管理する self.lyricを作成する。

def __init__(self):
    self.__d = {}
    self.tag = '[#UNDEFINED]'
    self.lyric = None
    self._alternative_tempo = None

__str__

文字列出力するフォーマット

def __str__(self):
    return f'{self.tag} {self.lyric}\t<utaupy.ust.Note object>'
    # '[#0000] か    <utaupy.ust.Note object>'

property: values

ノートの各種パラメータを辞書で取得または上書きする。

# Getter
d = note.values  # type(d): dict
# Setter
note.values = d  # type(d): dict

property: tag

ノートのエントリを識別するタグを取得または上書きする。'[#SETTING]' とか '[#0000]' とか。

# Getter
s = note.tag  # type(s): str
# Setter
note.tag = s  # type(s): str

print(note.tag)  # '[#0000]' (for example)

property: length

# Getter
s = note.tag  # type(s): str
# Setter
note.tag = s  # type(s): str

print(note.tag)  # '[#0000]' (for example)

property: length_ms

# Getter
s = note.tag  # type(s): str
# Setter
note.tag = s  # type(s): str

print(note.tag)  # '[#0000]' (for example)

property: lyric

# Getter
s = note.tag  # type(s): str
# Setter
note.tag = s  # type(s): str

print(note.tag)  # '[#0000]' (for example)

property: notenum

# Getter
s = note.tag  # type(s): str
# Setter
note.tag = s  # type(s): str

print(note.tag)  # '[#0000]' (for example)

property: tempo

ノートのある位置でのテンポを取得または上書きする。 Setterとして使用した場合、直後に上位Ustオブジェクトの Ust.reload_tempo() の実行を推奨。

# Getter
n = note.tempo  # type(n): float
print(n)        # float 100.0 (for example)

# Setter
note.tempo = 120
print(note.tempo) # float 120.0
# After setting tempo, please do 'reload_tempo()' of Ust object which contains the Note object.
ust.reload_tempo()

get_by_key

任意のパラメータを取得する。存在しない場合 KeyError になる。

Get the parameter of note, by key you like. This may raise KeyError.

get_by_key('Modulation')  # '0'
get_by_key('Lyric')  # 'a か'
get_by_key('Tag')  # '[#0000]'

set_by_key

任意のパラメータを新規登録または上書きする。

print(get_by_key('Modulation'))  # KeyError
note.set_by_key('Modulation', 0)
print(get_by_key('Modulation'))  # '0'

delete

print(note.tag)  # '[#0000]'
note.refresh()
print(note.tag)  # '[#DELETE]'

insert

Not reccomended to use

print(note.tag)  # '[#0000]'
note.refresh()
print(note.tag)  # '[#INSERT]'

refresh

print(note.tag)  # '[#0000]'
note.refresh()
print(note.tag)  # '[#DELETE]\n[#INSERT]'

suppin

ノートの情報を最小限にする

note.suppin()

utaupy.otoini

UTAUの原音設定ファイルを扱うモジュール。setParamでの利用を想定。


OtoIni(collections.UserList)

oto.ini ファイルを扱うためのクラス。list を継承。


Oto(collections.UserDict)

oto.ini に含まれる各原音のパラメータを扱うクラス。


utaupy.table

かなローマ字変換表などを扱うモジュール。

utaupy.convert

Ust オブジェクト、OtoIni オブジェクト、Label オブジェクトなどを変換するモジュール。

utaupy.reaper

REAPER (DAW) のリージョン・マーカー用CSVファイルを扱うモジュール。

utaupy.utau

UTAUエディタで行う操作の代替と、UTAU音源の原音値取得などをするモジュール。「パラメータ自動調整」などができる。

utaupy.utauplugin

UTAUプラグインをつくるためのモジュール。utaupy.utauplugin.UtauPlugin クラスは utaupy.ust.Ust を継承し、プラグイン用に最適化した子クラス。

使用例として半音上げプラグインを貼っておきます。

import utaupy

def notenum_plus1(utauplugin):
    """
    utauplugin: utaupy.utauplugin.UtauPlugin class object
    全てのノートを半音上げる
    """
    # UtauPluginオブジェクトのうちノート部分を取得
    notes = utauplugin.notes
    # 半音上げ
    for note in notes:
        note.notenum += 1

if __name__ == '__main__':
    # automatically 
        # read the utau plugin script
        # load as utaupy.utauplugin.UtauPlugin class object
        # overwrite the utau plugin script
    utaupy.utauplugin.run(notenum_plus1)

連絡先

  • Twitter: @oatsu_c

  • GitHub: oatsu-gh

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

utaupy-1.10.0.tar.gz (31.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

utaupy-1.10.0-py3-none-any.whl (34.7 kB view details)

Uploaded Python 3

File details

Details for the file utaupy-1.10.0.tar.gz.

File metadata

  • Download URL: utaupy-1.10.0.tar.gz
  • Upload date:
  • Size: 31.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for utaupy-1.10.0.tar.gz
Algorithm Hash digest
SHA256 880697f2f59a988b23b227b51ad2b87835de7185af1f26b2d10e761ced97bf3c
MD5 b06cd343555ea565e50df9aece680826
BLAKE2b-256 dd627f061f230dae9e77802576ed0f34cd020f1fc8e0ae92dde77016adf9b96a

See more details on using hashes here.

File details

Details for the file utaupy-1.10.0-py3-none-any.whl.

File metadata

  • Download URL: utaupy-1.10.0-py3-none-any.whl
  • Upload date:
  • Size: 34.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for utaupy-1.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fcdb8331f1b1d6bfbce172009e3c2a03287786a3d7c83f469bf052c5004515a4
MD5 8f7daf3042ab6a4db2288e6a25684c2a
BLAKE2b-256 82997c539c5126a9d9c2849966490b04727d477b25c6da73f2e641f61b58bb15

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page