ЛИСТИНГИ ИСХОДНЫХ КОДОВ РАБОЧЕЙ ВЕРСИИ РЭП-ГЕНЕРАТОРА
Как обещал, выкладываю. Из Discord Radio Player 1.2.4, в котором создан альбом выше. Для ознакомительных целей....
RapConfig.cs
Rap.csКод:using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; using System.IO; namespace MachineSpeechLibrary { public class RapConfig { private const string ConfigFileName = "RapConfig.txt"; public string locale = "en-US"; public string[] morphems = new string[] { "a","the","is","was","yes","no","are","you","we","he", "she","it","as","me","iam", "low","bis","ness","less","near", "far","in","on","under","before","late","under","after","of","off", "po","pi","pu","py","pe","to","ti","tu","te","ro", "ru","ri","re","wo","wi","wu","qo", "qi","qu","qe","pa","ta","ra","wa","qa","sa","da", "fa","ga","ha","ja","ka","la","lo","li","lu","le", "ly","le","ko","ki","ku","ky","ke","jo","ji","ju", "jy","je","ho","hi","hu","hy","he","go","gi","gu", "gy","ge","fo","fi","fu","fy","fe","do","di", "du","dy","de","so","si","su","sy","se","sistem","zo", "za","zi","zu","zy","ze","xo","xi","xu","xy","xe", "xa","co","ci","cu","cy","ce","ca","vo","vi","vu", "vy","va","bo","bi","bu","by","be","ba","no","ni", "nu","ny","ne","na","mo","mi","my","ma","mom","child", "guy","girl","father","mother","friend","boss", "sex","fuck","cock","dick","pussy","love","feel","like","seem", "exit","fail","quit","enter","login","run","press","start","stop","system","comp", "break","case","switch","net","inet","key","man","wooman", "all","wall","walk","go","inter","play","kiss","for","goto","mail","chat","client","soft", "ware","hard","dream","cosmo","planet","netpun","pluton","moon","sun","earth","mars", "volt","amper","kilo","mega","byte","bit","word","file","giga","milli","mini","nano", "buck","money","sum","plus","minus","multi","div","per","into","later","quick","finish", "write","code","hex","octal","dec","inc","move","push","pop","int","float","double","bool", "string","char","list","var","able","dis","lock","asm","see","cat","call","mask","ret", "out","space","wire","cur","rent","while","loop","each", "one","two","free","four","five","six","seven","eight","nine","ten","zero", "high","low","many","small","big","too" }; public void Save() { try { string s = JsonConvert.SerializeObject(this, Formatting.Indented); File.WriteAllText(ConfigFileName, s); } catch { } } public static RapConfig Load() { try { string s = File.ReadAllText(ConfigFileName); return (RapConfig)JsonConvert.DeserializeObject(s, typeof(RapConfig)); } catch { RapConfig cfg = new RapConfig(); cfg.Save(); return cfg; } } } }
MusicConfig.csКод:using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Speech.Synthesis; namespace MachineSpeechLibrary { public class Rap { protected string locale = "en-US"; protected string[] morphems = new string[] { }; public Rap(RapConfig config) { this.locale = config.locale; this.morphems = config.morphems; } protected Random rnd = new Random(); protected List<string> Word { get { int n = rnd.Next(2, 5); List<string> res = new List<string>(); for (int i = 0; i < n; i++) res.Add(morphems[rnd.Next(morphems.Length)]); return res; } } protected List<List<string>> Sentence { get { int n = rnd.Next(2, 5); List<List<string>> res = new List<List<string>>(); for (int i = 0; i < n; i++) res.Add(Word); return res; } } protected List<string> Rithma(List<string> word) { List<string> res = new List<string>(); foreach (string w in word) if (rnd.Next(10) < 8) res.Add(w); else res.Add(morphems[rnd.Next(morphems.Length)]); return res; } protected List<List<string>> Rithma(List<List<string>> sent) { List<List<string>> res = new List<List<string>>(); foreach (List<string> w in sent) res.Add(Rithma(w)); return res; } protected List<List<List<string>>> Kuplet_1 { get { List<List<List<string>>> res = new List<List<List<string>>>(); List<List<string>> sent1 = Sentence; List<List<string>> sent2 = Sentence; List<List<string>> sent3 = Rithma(sent1); List<List<string>> sent4 = Rithma(sent2); res.Add(sent1); res.Add(sent2); res.Add(sent3); res.Add(sent4); return res; } } protected List<List<List<string>>> Kuplet_2 { get { List<List<List<string>>> res = new List<List<List<string>>>(); List<List<string>> sent1 = Sentence; List<List<string>> sent2 = Rithma(sent1); List<List<string>> sent3 = Sentence; List<List<string>> sent4 = Rithma(sent3); res.Add(sent1); res.Add(sent2); res.Add(sent3); res.Add(sent4); return res; } } protected List<List<List<string>>> Kuplet_3 { get { List<List<List<string>>> res = new List<List<List<string>>>(); List<List<string>> sent1 = Sentence; List<List<string>> sent2 = Rithma(sent1); List<List<string>> sent3 = Rithma(sent1); List<List<string>> sent4 = Rithma(sent1); res.Add(sent1); res.Add(sent2); res.Add(sent3); res.Add(sent4); return res; } } protected List<List<List<string>>> Kuplet_4 { get { List<List<List<string>>> res = new List<List<List<string>>>(); List<List<string>> sent1 = Sentence; List<List<string>> sent2 = Sentence; List<List<string>> sent3 = Rithma(sent2); List<List<string>> sent4 = Rithma(sent1); res.Add(sent1); res.Add(sent2); res.Add(sent3); res.Add(sent4); return res; } } protected string WordText(List<string> word) { string res = ""; foreach (string w in word) res += w; return res; } protected string ToText(List<List<string>> sent) { string res = ""; foreach (List<string> w in sent) res += WordText(w) + " "; return res; } protected string ToText(List<List<List<string>>> kuplet) { string res = ""; foreach (List<List<string>> s in kuplet) res += ToText(s) + ". ";// "\r\n"; return res; } public string Poem { get { int n = rnd.Next(3, 10); string res = ""; for (int i = 0; i < n; i++) { int k = rnd.Next(4); switch(k) { case 0: res += ToText(Kuplet_1); break; case 1: res += ToText(Kuplet_2); break; case 2: res += ToText(Kuplet_3); break; case 3: res += ToText(Kuplet_4); break; } } return res; } } protected bool StopFlag = false; public bool IsPlaying = false; public async Task Play() { StopFlag = false; IsPlaying = true; try { SpeechSynthesizer syn = new SpeechSynthesizer(); syn.Rate = 4; syn.Volume = 99; syn.SelectVoiceByHints(VoiceGender.NotSet, VoiceAge.NotSet, 0, new System.Globalization.CultureInfo(locale)); while (!StopFlag) { syn.Speak(Poem); } } catch { } IsPlaying = false; } public void Stop() { StopFlag = true; } } }
Music.csКод:using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; using System.IO; namespace MachineSpeechLibrary { public class MusicConfig { private const string ConfigFileName = "MusicConfig.txt"; //------------------------------------------------------------------------- public int MinRithmRepeatCount = 1; public int MaxRithmRepeatCount = 5; public int MaxRithmChannels = 2; public int MinInstrumentChannels = 2; public int MaxInstrumentChannels = 5; //-------------------------------------------------------------------------- public string InstrumentFolder = "InstrumentSound"; public string[] RithmInstruments = new string[] { "банджо-ритм","деревяшки-ритм","испанский-ритм","лёгкий-ритм","метал-ритм", "металлический-барабан-ритм","панк-ритм","ритмичное-встряхивание", "тамбурин-ритм","тарелки-ритм","эхо-барабанов-ритм","ложки-ритм" }; public string[] Instruments = new string[] { "арфа","банджо","большая-тарелка","большой-гонг","бонго","бубен","бубенцы","волынка", "гонг","деревяшки","дробь","игра-на-гитаре","испанская-гитара","карильон","ксилофон", "марш","нейлоновые-струны","никельодеон","тарелки","треугольник","трещотка", "удар-по-тарелке","флейта","фортепиано-низы","хомус","церковный-орган","электрогитара" }; public void Save() { try { string s = JsonConvert.SerializeObject(this, Formatting.Indented); File.WriteAllText(ConfigFileName, s); } catch { } } public static MusicConfig Load() { try { string s = File.ReadAllText(ConfigFileName); return (MusicConfig)JsonConvert.DeserializeObject(s, typeof(MusicConfig)); } catch { MusicConfig cfg = new MusicConfig(); cfg.Save(); return cfg; } } } }
Код:using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MachineSpeechLibrary { public abstract class Music { string[] RithmInstruments = new string[] { }; string[] Instruments = new string[] { }; string FolderPath = ".\\"; int MinRithmRepeat = 1; int MaxRithmRepeat = 5; int MinRithmChannels = 1; int MaxRithmChannels = 2; int MinInstrumentChannels = 2; int MaxInstrumentChannels = 5; //---------------------------------------------------------------------------- public Music(MusicConfig config) { //----------------------------------------------------------------------- this.MinRithmRepeat = config.MinRithmRepeatCount; this.MaxRithmRepeat = config.MaxRithmRepeatCount; this.MinInstrumentChannels = config.MinInstrumentChannels; this.MaxInstrumentChannels = config.MaxInstrumentChannels; this.MaxRithmChannels = config.MaxRithmChannels; //----------------------------------------------------------------------- this.RithmInstruments = config.RithmInstruments; this.Instruments = config.Instruments; this.FolderPath = config.InstrumentFolder; } Random rnd = new Random(); protected int SamplesNumber { get { return 4 * rnd.Next(1, 20); } } protected string[] RitmChannel(int count) { List<string> list = new List<string>(); int n = rnd.Next(RithmInstruments.Length); for (int i = 0; i < count; i++) list.Add(RithmInstruments[n]+".mp3"); return list.ToArray<string>(); } protected string[] Channel(int count) { List<string> list = new List<string>(); int ins0 = rnd.Next(Instruments.Length); int ins1 = rnd.Next(Instruments.Length); int ins2 = rnd.Next(Instruments.Length); int ins3 = rnd.Next(Instruments.Length); for (int i = 0; i < count; i++) switch (i % 4) { case 0: list.Add(Instruments[ins0]+".mp3"); break; case 1: list.Add(Instruments[ins1]+".mp3"); break; case 2: list.Add(Instruments[ins2]+".mp3"); break; case 3: list.Add(Instruments[ins3]+".mp3"); break; } return list.ToArray<string>(); } public List<string[]> RithmChannels { get { int r = rnd.Next(MinRithmChannels, MaxRithmChannels); List<string[]> rit = new List<string[]>(); int count = rnd.Next(MinRithmRepeat, MaxRithmRepeat); for (int i = 0; i < r; i++) rit.Add(RitmChannel(count)); return rit; } } protected bool StopFlag = false; protected bool[] IsRithmPlaying = new bool[20]; public abstract Task PlayMp3FileAsync(string folder, string mp3file); //public void SetInstrumentsFolder(string FolderPath) { this.FolderPath = FolderPath; } public bool IsPlaying = false; protected async Task PlayChannel(string[] instruments) { try { for (int i = 0; i < instruments.Length && !StopFlag; i++) { await Task.Delay(100); await PlayMp3FileAsync(FolderPath, instruments[i]); } } catch { } } protected async Task PlayRithmChannel(int ChannelNumber, string[] instruments) { IsRithmPlaying[ChannelNumber] = true; try { for (int i = 0; i < instruments.Length && !StopFlag; i++) { await Task.Delay(100); await PlayMp3FileAsync(FolderPath, instruments[i]); } } catch { } IsRithmPlaying[ChannelNumber] = false; } public bool IsRithm { get { foreach (bool b in IsRithmPlaying) if (b) return true; return false; } } public async Task Play() { StopFlag = false; if (IsPlaying) return; else IsPlaying = true; for (int i = 0; i < IsRithmPlaying.Length; i++) IsRithmPlaying[i] = false; while (!StopFlag) try { List<Task> list = new List<Task>(); List<string[]> rithm = RithmChannels; for (int i = 0; i < rithm.Count; i++) { Task.Run(() => PlayRithmChannel(i, rithm[i])); await Task.Delay(500); } while (IsRithm && !StopFlag) { int c = rnd.Next(MinInstrumentChannels, MaxInstrumentChannels); List<string[]> channels = new List<string[]>(); for (int i = 0; i < c; i++) channels.Add(Channel(12)); for (int i = 0; i < channels.Count && !StopFlag; i++) { list.Add(PlayChannel(channels[i])); await Task.Delay(500); } Task.WaitAll(list.ToArray<Task>()); } } catch { } IsPlaying = false; for (int i = 0; i < IsRithmPlaying.Length; i++) IsRithmPlaying[i] = false; } public void Stop() { StopFlag = true; } } }
MusicPlayer.cs
Код:public class MusicPlayer : Music { public MusicPlayer(MusicConfig config) : base(config) { } public override Task PlayMp3FileAsync(string folder, string file) { WMPLib.WindowsMediaPlayer player = new WMPLib.WindowsMediaPlayer(); player.URL = Path.Combine(folder, file); try { player.controls.play(); } catch { } return Task.Run(async () => { await Task.Delay(1500); while ( player.playState == WMPPlayState.wmppsBuffering || player.playState == WMPPlayState.wmppsPaused || player.playState == WMPPlayState.wmppsPlaying) await Task.Delay(75); }); } }
СКАЧАТЬ РАБОЧИЙ РЭП-ГЕНЕРАТОР ПЛАГИНОМ К МЕНЕДЖЕРУ КИБЕР-ФАЙЛ 2.5.4
Я спустил рабочую версию рэп-генератора DiscordRadio 1.2.4 плагином последней версии файлового менеджера для хакеров КиберФайл 2.5.4. Генератор генерирует каунтри, готический рэп, тексты песен на любом языке и любую музыку по сэмплам, для чего введена поддержка JSON - конфигов в человеко-машинном формате. Генератор полностью бесплатен, демо-версия менеджера ограничена 5 минутами работы на каждый запуск. Скачать можно [Только зарегистрированные могут видеть это. ]
Сегодня скачал сэмплы для монтажа рэп-композиций и добавил в генератор Discord Radio, записал 20 минут чистого искусственного интеллекта в стиле рэп. Получилось, весьма неплохо, музыка не шедевр но интересна оригинальным стилем а английский машинный рэпчик под неё делает композицию приятной для прослушивания. На улице на телефоне я уже ничего кроме искусственного интеллекта в стиле рэп не слушаю :-)
Последний раз редактировалось Talomir Mirotal; 29.06.2022 в 21:46.
Закачал, можно послушать композицию anti-zombak-pure-AI.mp3, сделанную в Discord Radio с генератором хип-хопа, генератором речетатива и джаммером. 30 минут звучания машинного хип-хопа с джаммом, вырубают наведённую внутреннюю речь и просто нормально звучат пока убиваешь время. Правильное название машинному творчеству конечно - настоящий брейкбит, но я брал сэмплы инструментов из хип-хопа, так что это брейкбит-хоп!
СКАЧАТЬ [Только зарегистрированные могут видеть это. ]
|
|
|