Article
5 min read
When artificial intelligence writes folk songs
AI is regarded as an important tool for Industry 4.0, as it plays an increasingly important role, among others, in predictive maintenance and quality control automation, However, among the many application areas of the technology, there are also some really funny developments. Recently, we were involved in an exciting project that resulted in the creation of an artificial intelligence-based folk songwriting chatbot called KukoricAIános (the moniker is a pun derived from the hero of a popular folk ballad). How did we get started and what challenges did we face in the course of work? Read our article below to find out!

Project background and objective
The development project was realised under the auspices of the Artificial Intelligence (AI) Coalition, in cooperation with Zeneszöveg.hu, a website specialising in song lyrics. The objective of the project was to create an application that can compose a completely new folk song based on a category pre-selected by the user. The end result was defined, on the one hand, as a folk song generated by artificial intelligence, and, on the other hand, as an original folk song that best resembles it.
Technical background
During the project, we resorted to A.N.I.T.A., an existing Stratis artificial intelligence capable of performing natural language processing (NLP). During implementation, we faced three main challenges:
1. Building a model for generating new folk songs
The first question we asked ourselves is how can AI be enabled to generate verses, or even complete songs? As a solution, two methods came up: one was to train A.N.I.T.A. to generate the general Hungarian language and within that to write folk songs, and the other was to train it exclusively on the folk song corpus. Given the preliminary results, the amount of data available, and the resources, we finally opted for the second approach. In the next phase of implementation, several artificial intelligence models were tested, among which a simple recurrent neural network (RNN) was chosen based on the quality of the generated lyrics.
2. Categorisation of the generated songs
Fortunately, this process did not pose any difficulty for A.N.I.T.A.: In the song corpus, we gave each song a label, and with the help of supervised ttraining we prepared the score grader.
3. Finding an existing song resembling the generated one
When the program completes the lyrics of the four-line song, it also signals us which one it thinks to be the closest existing folk song. We assumed two songs to be similar if their categories were the same and there were as few differences in their wording as possible. On this basis, we created the most similar song using a TFIDF vectoriser and the NearestNeighbour algorithm. The data flow is nicely illustrated in the following figure:

From data to chatbot
This brought us to the last step of the project, which was to deliver the completed data to the users. Facebook's (Meta) Messenger application proved to be the perfect platform for this. We then used the Flask package in Python language to create a chatbot that could interactively respond to different inputs. Thus, the user just sends the word "song" in a message and then can choose from 3 different categories (sorrowful, love, surprise) depending on the mood of the song he/she wants to receive. In each case, the AI generates a completely unique four-line folk song, which the user can then score from 1 to 5 and give the poem a title. In the case where the chatbot receives a message that it cannot interpret, it will redirect the user to the Zeneszöveg.hu customer service.
The project has demonstrated that A.N.I.T.A.'s features can be applied in a number of areas, including songwriting. Of course, our vertically integrated artificial intelligence model will still not sing a song, but it is now able to write funny folksy lyrics via the zeneszoveg.hu chatbot.
Are you interested in our project and A.N.I.T.A? Find out more about our proprietary AI-based solution, do not hesitate to contact us!
About author

Gáspár Sándor has been leading Stratis' artificial intelligence division since 2020, bringing over 20 years of experience in data science. Together with his team, he develops machine learning-powered decision support solutions for large enterprises, leveraging our clients' existing data assets. Additionally, he assists in automating our clients' existing processes using deep neural networks-based NLP and machine vision solutions.