import os, sys sys.path.append(os.getcwd()) import sure import melete.lyrics as Lyrics import melete.rhythm as Rhythm Lyrics.split_by_mora(u'ニャーンカッパ').should.be.equal([u'ニャ', u'ー', u'ン', u'カ', u'ッ', u'パ']) Lyrics.split_by_mora(u'ニャ_ーン^カッ_パ').should.be.equal([u'ニャ_', u'ー', u'ン^', u'カ', u'ッ_', u'パ']) Lyrics.insert_accent(u'ハシ', 1).should.be.equal(u'ハ_シ') Lyrics.insert_accent(u'ハシ', 2).should.be.equal(u'ハ^シ_') Lyrics.insert_accent(u'ハシ', 0).should.be.equal(u'ハ^シ') Lyrics.analyze(u'お釣り') #アクセント型がない l = Lyrics.analyze(u'矢澤にこ===星空凛') l[0]['phoneme'].should.be.equal(u'ヤ^ザワ/ニ^コ_/') l[1]['phoneme'].should.be.equal(u'ホ^シゾラ/リ_ン/') rhythms = [ [], [0], [0, 12], [12, 24, 36], [0, 12, 24, 36], [0, 6, 12, 24, 36], [0, 6, 12, 18, 24, 36], [0, 6, 12, 18, 24, 30, 36], [0, 6, 12, 18, 24, 30, 36, 42] ]
sys.path.append(os.getcwd()) from datetime import datetime as dt import mido import sure import melete.lyrics as Lyrics import melete.rhythm as Rhythm import melete.chord as Chord import melete.melody as Melody ts = Rhythm.TimeSignature(4, 2) rhythms = [[0], [0, 96], [48, 96, 144], [0, 48, 96, 144]] tree = Rhythm.RhythmTree(48, 1, ts, rhythms) text = u'ぽよぽよぽよぽよぽよぽよぽよぽよ===あるう ひ もりのな か くまさん に であっ た あるう ひ もりのな か くまさん に であっ た' lyrics = Lyrics.analyze(text) lyrics = map(lambda l: Lyrics.divide(l['phoneme'], tree), lyrics) beats = map(lambda l: Lyrics.pair(l, tree), lyrics) c = Chord.Chord.from_name('C') f = Chord.Chord.from_name('F') f.inversion(1) gsus4 = Chord.Chord.from_name('Gsus4') gsus4.inversion(1) prog = Chord.ChordProg(48, 4, [(c, 0), (f, 192), (gsus4, 384), (c, 576)]) note_range = range(Chord.Scale.from_name('C4').note, Chord.Scale.from_name('A5').note) with mido.MidiFile(ticks_per_beat=48, charset='utf-8') as midi: for beat in beats: composer = Melody.Composer(ts, beat, prog, note_range, 0.5, 180)
# -*- coding: utf-8 -*- import os, string, random import sure import melete.lyrics as Lyrics import melete.rhythm as Rhythm import melete.chord as Chord import melete.melody as Melody ts = Rhythm.TimeSignature(4, 2) rhythms = [[0], [0, 96], [48, 96, 144], [0, 48, 96, 144]] tree = Rhythm.RhythmTree(48, 1, ts, rhythms) text = u'ぽよぽよぽよぽよぽよぽよぽよぽよ===あるう ひ もりのな か くまさん に であっ た あるう ひ もりのな か くまさん に であっ た' lyrics = Lyrics.analyze(text) lyrics = map(lambda l: Lyrics.divide(l['phoneme'], tree), lyrics) beats = map(lambda l: Lyrics.pair(l, tree), lyrics) c = Chord.Chord.from_name('C') f = Chord.Chord.from_name('F') f.inversion(1) gsus4 = Chord.Chord.from_name('Gsus4') gsus4.inversion(1) prog = Chord.ChordProg(48, 4, [(c, 0), (f, 192), (gsus4, 384), (c, 576)]) note_range = Chord.note_range('C4', 'A5') patterns = [{ 0.125: {'length': 0.125, 'notes': [0]}, 0.25: {'length': 0.25, 'notes': [1, 2]},
def analyze_lyrics(): return jsonify({'tunes': Lyrics.analyze(request.form['text'])})
# -*- coding: utf-8 -*- import sure import melete.lyrics as Lyrics import melete.rhythm as Rhythm Lyrics.split_by_mora(u'ニャーンカッパ').should.be.equal([u'ニャ', u'ー', u'ン', u'カ', u'ッ', u'パ']) Lyrics.split_by_mora(u'ニャ_ーン^カッ_パ').should.be.equal([u'ニャ_', u'ー', u'ン^', u'カ', u'ッ_', u'パ']) Lyrics.insert_accent(u'ハシ', 1).should.be.equal(u'ハ_シ') Lyrics.insert_accent(u'ハシ', 2).should.be.equal(u'ハ^シ_') Lyrics.insert_accent(u'ハシ', 0).should.be.equal(u'ハ^シ') Lyrics.analyze(u'お釣り') #アクセント型がない l = Lyrics.analyze(u'矢澤にこ===星空凛') l[0]['phoneme'].should.be.equal(u'ヤ^ザワ/ニ^コ_/') l[1]['phoneme'].should.be.equal(u'ホ^シゾラ/リ_ン/') rhythms = [ [], [0], [0, 12], [12, 24, 36], [0, 12, 24, 36], [0, 6, 12, 24, 36], [0, 6, 12, 18, 24, 36], [0, 6, 12, 18, 24, 30, 36], [0, 6, 12, 18, 24, 30, 36, 42] ] rhythm_tree = Rhythm.RhythmTree(12, 1, Rhythm.TimeSignature(4, 2), rhythms) lyric = u'ア^イウ/ア^イウエ/ア^イウエ_オ/ /カキク/ / /'