Categories
Uncategorized

Project Progress

My Project

The project that I have been working on this year is a Top-N Genre Classification Neural Network. This neural network allows users to use a CLI app to detect the genres of user-provided audio files. The way that it classifies them is by generating a list of genres each with a numeric “confidence value”. These values describe how confident the model is that the genre matches the given audio clip.

This project is split into two main portions: neural network development and training, and the input preprocessing. Input preprocessing was my task which meant that I had to figure out how to convert the audio files into a format that the model could read. This is important for converting the user’s audio files and also for building the dataset that would train the model.

Why I chose it

The reason I decided to join this project is because of my passion for music and my knowledge of music theory. I have always wanted to combine my interest in computer science with my interest in music and this was the perfect opportunity to learn more. I once wrote a ‘Formal Proposal’ for a course of a project practically identical to the one we are working on now.

I also believed that I could provide a lot of insight into the musical aspects of the project. I have a lot of experience with playing music and studying theory. This made it easier to decide things like what genres to use and how to avoid biases when it comes to something so subjective. It also helped us decide whether to store data as spectrograms or mel-spectrograms.

What have I learned

One of the biggest things that I have learned much more about is how computers interact with audio. I had never thought much about it before and it was very interesting to see how we can measure sound with computers. At first, we started with mel-spectrogram jpg images, a visual representation of audio as a graph of colors. This worked for a while but we eventually moved on to MFCCs which are the values of the spectrogram represented as a two dimensional array of numbers. Seeing these representations of audio was very new to me and working with them really helped me to understand how they are calculated.

I also unintentionally gained some knowledge on machine learning and how I can build my own in Python. I found out about the Tensorflow library and some standard procedures of how to build an accurate dataset to train a machine learning model. I also learned about the librosa library and how it can be used to process audio data in Python. All of this work has really grown my interest in AI and helped me get a better idea of what fields I would enjoy going into as I move forward with my career.

Categories
Uncategorized

Technology

Responsibilities

I am in charge of a fairly specific part of my Genre Classification Neural Network project. In order for our machine learning model to process audio, we need some way to convert it to a format the model can read. My job is to build this bridge by producing a process that can effectively convert audio files into spectrogram images.

Technologies

The most crucial technology that I use for this portion of the project is a Python library called Librosa. Librosa takes audio files and converts them into usable data such as waveforms, spectrograms, or MFCCs (which is what we will likely be using from this point on in our project). This conversion from spectrograms to MFCCs is a little intimidating to me but the good news is that the two processes will be very similar by using Librosa.

One of the biggest challenges that we have run into while working through this project is Librosa’s inability to elegantly process some audio file types. So far, it has no problem processing .au and .mp3 files but when we wanted to start running files like mp4, m4a, and webm it became a bit more of a struggle. My teammate who is in charge of building out the dataset found a quick solution before I could, which was a built-in program called ffmpeg. Librosa automatically runs files using other tools such as ffmpeg and audio-read which has been super useful.

Products

Spectrograms are a type of image used to interpret audio visually. Typically, it is a measurement of frequency in terms of time with an added color intensity representing density. Below is an example of a person saying the words “nineteenth century”. This was our initial plan for the input into the neural network but we realized that converting directly from audio to MFCC would be a bit more efficient.

MFCCs are a lot like spectrograms. Much of the process to create them is exactly the same. The difference is that MFCCs are a representation of audio through arrays of numbers rather than visual. This makes it easy to use json files rather than thousands of jpegs of spectrograms. Additionally, these MFCCs can be bunched together and placed into single json files rather than producing an output file for every single audio file in the database.

Sources

https://en.wikipedia.org/wiki/Spectrogram

Categories
Uncategorized

Clean Code

Introduction

As an engineer, I am very particular about the way my space looks. I keep my bedroom neat and tidy with no misused space. However, as an artist, I also do not leave any space on my wall uncovered by a picture, shelf, or tapestry (as long as it isn’t cluttered of course). Because I work and take classes from home, it is often hard to separate my work and home life. But the one principle I take into both, is neatness and organization.

Keeping my code clean is a way of keeping my computer screen organized. I like to operate in an extremely controlled environment and when my workspace gets jumbled, it makes it difficult for me to work. I see my computer as another decoration in my room and I like it to look just as neat as everything else. Which is why I emphasize my code’s cleanliness in school, work, and even my own personal projects.

What makes code clean?

There is no one “right” way to write clean code. If every musician had the same vision for the perfect piece, there would be no diversity in your playlists. That is why it is important to note that there is an art to coding and everyone has their own personal style. Not everyone will follow the exact same formatting rules because not everyone visualizes the code on the screen in the same way. However, there are many important standards and practices that should be followed in order for your code to be legible to others.

I will be going through a few key topics that are highlighted in this article written by German Cocca: https://www.freecodecamp.org/news/how-to-write-clean-code/. The article discusses a wide variety of clean code principles but a few of my favorites that I would like to focus on in my code-writing career have to do with efficiency and consistency.

Efficiency

When it comes to coding, efficiency and legibility go hand in hand. If you write long, convoluted code, it will be extremely difficult to go back and debug, regardless of it works or not. The image below is an example of inefficient code.

Obviously, this code was written as a joke. But it can be used as a good exercise for writing clean code as we find a solution with only one line in the body of the function. Although basic, the below function is a great demonstration of how we can rewrite code to be clean and efficient.

private bool IsEven(int number){
    return (number % 2 == 0);
}

Consistency

Consistency is one of my favorite parts of my coding. It creates aesthetically pleasing code that is easy to follow. A piece of code with proper and consistent formatting is like a work of art to me. I always love looking back over my code and seeing everything fall into place like a big puzzle.

The great thing about consistency is that it doesn’t require you to be consistent in any specific way. You are able to personalize your formatting for functions and variables as long as you are consistent. One of my favorite examples of this is case conventions. There are a variety of different case conventions such as camelCase, PascalCase, and snake_case (demonstrated within the name). All of these are completely valid but it is up to the coder to decide what they like best. My personal favorite case conventions are snake_case for function declarations and camelCase for variables.

Code Smells

Apart from writing clean code, it is also important to watch out for things called “code smells”. This article written by Georgina McFadyen describes a few examples of these: https://8thlight.com/insights/common-code-smells. One example that caught my eye (because I do this) was data clumps. Data clumps happen when related variables are often called together repeatedly. One example I found from my own project was:

func add_coll_object(objPosition, function, scene, object):

All of the parameters of this function are aspects of every coll_object but they are all passed through my code separately which often gets very confusing. After reading through this article on code smells, I see that this is a much inferior method of handling these variables. I actually took a break from this project because the way that I wrote it initially became too much of a headache to figure out but now I have the tools to fix it. I am very glad that the research for this blog post could shine a light on the real problem in my project.

Categories
Uncategorized

Blog Post #3

Working on Holiday

This Thanksgiving weekend has felt like an eventful trip. As my group and I planned out our v0.0.2 assignment, I realized that I was going to have another big assignment due right before it. On top of that, I was travelling home for the holidays and didn’t have a ton of time to pour into school since I was spending time with family. All of these factors forced me to come up with a plan to figure out how I can get everything done efficiently and still have free time for the holidays.

My biggest worry was my Operating Systems course which is formatted in a very sparser manner. Throughout the course, we only had five quizzes, one final project, one final report, and a final exam. Until now, I had only done the quizzes without giving the end of the course much thought. Recently, when the fourth quiz forced me to take a syllabus quiz, I realized how underprepared I was for the final project and report.

I was able to come up with a quick solution to lessen my workload for that class by recognizing the option for collaborators. I found another student who had not found a group yet and we were able to quickly make a plan to get the first section of our projects done in time. Through this experience, I learned how useful and important group learning and team work can be.

As I was going through that whole process of finding a team, I was able to come up with a plan to get my work done for my Capstone project as well. This week, I was the Scrum Master, meaning that I had to compile all of our work and do the final submission. This means that I had a very important task and needed to make sure I had time to do it. As soon as I realized that I was going to struggle with time, I informed my team and gave them an exact timeline of when I would be able to work. This provided them with the necessary guidance to get me everything I would need for the submission on time.

Project Progress

As for the project itself, things went really well this week. The final product that we are looking for is becoming clearer and clearer. Despite all of the time constraints we had due to the holidays and other projects, everyone did their part and every aspect of the project was improved. After I expressed that I was going to have trouble with time, my group members all pitched in to help fill in the slideshow so that I wouldn’t have to spend too much time on it.

If you don’t know what our project is about, it is a Top-N Genre Classification Neural Network Application. We are designing a machine learning model that is able to listen to an audio file and give the user a list of genres associated with that audio with different “confidence scores” attached to them. We split the project into a few different sections: Dataset Acquisition, Audio Input Preprocessing, Traditional Neural Network Programming, and BlueSky Neural Network. My responsibility in this project is setting up the audio input pre-processing.

Over the first week of implementation, I did a lot of research on librosa, a Python library for audio processing. I used librosa to convert audio files into visual spectrograms to represent the audio in a way that the neural networks could understand. Unfortunately, the first implementation of the neural network was not able to use these spectrogram images but instead needed MFCC data in the form of a json file. Luckily, the team was able to quickly work together to make a MFCC generation script as well but we still wanted to find a use for the images..

This week, our traditional neural network team was able to set up a new neural network processor that is capable of using the spectrogram images. This left me with some work to do with the Dataset Acquisition team to optimize both of the generators. We communicated to come up with some ideas to make the generators run faster so we could deliver the dataset to the neural networks as soon as possible. I also made a few tweaks just so that the dataset team could use the interface of my generators easier and more flexibly. For example, the generators now automatically filter the directory down to only audio files and you are also able to input a directory at any location in your computer to gather and store them.

Conclusion

I learned many lessons over the course of this weekend:

  • I learned that I need to plan ahead more often so I don’t end up in situations like this.
  • I learned the importance of asking questions and working together with others.
  • I learned how to communicate with others in a team environment to make plans and share ideas.

All of these lessons will be skills that I can carry with me throughout the rest of my academic career and my work-life moving forward. I realized that I can succeed in my work and school life while still leaving plenty of time for friends and family. All I need is thorough planning and foresight to make sure that I stay ahead on my responsibilities.

Categories
Uncategorized

Blog Post #2

Introduction

Hello everybody, since my last blog post, I have decided upon my project and have almost begun the development phase! I have been working on creating a Top-N Genre Classification Neural Network. To be more specific, an AI machine learning model capable of classifying genres by receiving audio files and returning a list of genres with “confidence scores”. Music is a huge part of my life which is why I really wanted to find a project that matched my passion for the art. I am so glad that I am able to be a part of something I am excited for and passionate about.

Picking a Project

There were many projects to choose from and a lot of them looked intriguing to me. Particularly, I would have also enjoyed the other options centered around game design and/or music. The reason why this project was so appealing to me is because I have had the idea before! In my freshman year in 2022, I distinctly remember being very proud of my “formal proposal” assignment for my technical writing course. I proposed an AI machine learning model that can categorize music based on things like emotion and genre by finding its chord progressions, melodies, lyrics, etc. My current project is a lot simpler than this but maybe I can use what I learn to develop my initial idea!

Time Management

Balancing my work life, school work, friends, and family has been a bit of a struggle this term but I have found some great ways to manage it. I will break down some of my habits one topic at a time:

I started an internship over the summer and learned a lot about the Microsoft Power platform. I was able to provide so much efficiency to the department that they decided to keep me around over the school year! Over the course of this term, I have been trying to work around 20 hours a week in the mornings on weekdays. This has been plenty of time for me to continue making an impact on my department while also giving me plenty of time for other things. I think the best way I have been able to manage this is by holding myself to a set start time each day. I wake up every morning and log onto my work computer at 8. Depending on what projects my boss has for me to work on and what school work I need to finish afterwards, I clock out whenever it makes sense to.

Obviously this is not possible for everyone’s situation but I think there is some merit to deciding specific times to start working. In fact, I have started doing this with my school work too. In the past, I have spent many nights finishing assignments late due to poor planning and procrastination. Since I have started working, I have pretty much been forced to manage my time in order to not fall behind. I have basically dedicated the time I would have spent working when I was on full time to doing my school work. I have also dedicated certain days to specific assignments ahead of time giving me plenty of time to catch up if assignments take longer than I expect.

All of this planning and scheduling may make it seem as though I have no free time and I spend every waking moment working or studying. But this couldn’t be farther from the truth! Due to my dedication to planning during this term, I have had more time to hang out with my friends and roommates than I ever did over my last two years at OSU. I find that setting times and dates to complete assignments gives me a goal for that day and makes me work a lot faster and more focused. So, ironically, putting a little bit more time into planning has given me more freedom than I’ve ever had while in school.

Conclusion

This term has been very unique from the rest of my college career. My first internship, my capstone project, and living independently with five of my friends has been a big adjustment but also very rewarding. My internship has been super encouraging since it started out as being something I had never done before and turned me into one of the best in the field for the company. In this course, working with a group on a long-term project has definitely given me some stress but I am super excited about the project and am optimistic about my team. And finally, although my planning has helped, a big reason I have so much time to spend with my friends is because we all live together and can hang out any time! Overall, this term has been super fun for me and I am encouraged to keep moving throughout the rest of the school year. I have been branching out with new people and trying things that I wasn’t confident about before such as volleyball and playing more music! I am excited to continue down this path, learn many new things, and finish out the rest of my project.

Categories
Uncategorized

My First Blog Post

Introduction

Hello everybody, my name is Brandon Nguyen. I am a third year computer science major here at OSU. I am currently living in Corvallis near campus but I have been taking a lot of online classes recently so I can have more freedom to travel between here and my home in Washington. Back home, I have two orange cats and two dogs (a big reason why I’ve been travelling home more frequently).

As far as hobbies go, I love to stay active. I try to work out and play as many different sports as I can. This past summer, I started to play a lot of volleyball. I would play nearly three to four times a week with some family-friends I recently connected with. I’m super bummed that the weather is starting to get gloomy but I’m excited to try out indoor volleyball and maybe some new activities.

While I spend a lot of time being active, I also love to be creative. My favorite art form being music. I started my music path with piano lessons when I was four years old. From then on I started to sing along to the car radio (I still love 2000-2010s pop) and interact with music every chance I got. I joined a dance studio when I turned seven and joined the middle choir in sixth grade. Choir was the one I stuck to the most. I even ended up being voted choir president in my senior year of high school!

Getting started with Computer Science

I started getting interested in computer science for many reasons that I ended up finding throughout my high school years. Like many in this field, I have been playing video games for all my life. I loved playing things like Skylanders and Minecraft as a kid and as I grew older I started wanting to make things like that myself. Throughout school, I always excelled in math and loved to challenge myself with strategy games and logic puzzles. When I got to high school and started getting my Associates degree through the Running Start program, I took a few computer classes and realized this is exactly what I had been training for my whole life! Many coding problems feel just like those puzzles to me and I have a lot of fun working things out.

As a Vietnamese Washingtonian interested in computer science, I really wanted to go to the University of Washington but I didn’t end up making it into their competitive computer science program. But I wasn’t too upset since I had been debating between UW and OSU since I had tons of friends that would be coming here with me. Once I got here and started taking real programming and software development classes, I only got more and more interested.

Moving forward with Computer Science

This past summer, I landed an internship with Washington Trust Bank where I work with a lot of Microsoft products to improve the processes in my sector of the bank. I had to learn Microsoft Excel and helped my team learn more about the Power platform with Automate and BI. I have been having a ton of fun learning something new on my own and being able to provide continuous improvements for my team and see their reactions. However, this is not exactly what I have in mind for my computer science career.

One worry I had regarding my computer science journey was how I am going to incorporate my creative interests into my career. As I started taking classes like networking and algorithms, sometimes I would get tired of the rigid structure of the material. But after looking through the projects options for my Senior Software Engineering Project course, I have a lot of hope for my future. All of the projects related to music and making games have brought my passion for computer science full circle. I am super excited for the year to come and I have regained a ton of confidence in my computer science decision.

Categories
Uncategorized

Hello world!

Welcome to blogs.oregonstate.edu. This is your first post. Edit or delete it, then start blogging!