Friday, March 29, 2024

AI ChatGTP and music

One idea for this year is to make more use of AI in my projects. On my last blogpost about Python pandas i added an AI generated picture. The picture below is a result of quick experiments with 'NightCafe AI Art Creator' to make an illustration about 'AI generated music', the topic of this blogpost. My first attempts only gave a paper with music notes or some orchestra. so it was a bit of a challenge to get something nice.

AI generated music picture
AI generated music (NightCafe AI Art Creator)

My post about Python pandas also triggered me to take a look at other blogposts i have done to look if more pictures added something. For example a blogpost about Mysteries in ChatGPT had almost no illustrations and could need something extra. To go over older blogposts and add make changes did not give a good feeling. I like to limit changes in posts, however i also like to experiment with AI.

To try something complete different i did let another AI  (Sono) generate a song about Mysteries in ChatGPT :


The video (on my YouTube channel.) is complete generated with Suno . I hope you will play it to hear the result.
Python pandas
Python pandas
(NightCafe AI Art Creator)

I did not play a lot with Suno, and you only get a limited amount of 'virtual credits'to experiment. The interface (on my phone) did give me some problems and by accident i created multiple songs with the same input that where not much different from each other. 
I also created songs as mp3 audio files about 'Python pandas' . Unfortunately it is not easy possible to post audiofiles on this google blog. Therefore i created a video using the 'NightCafe AI Art Creator' picture as background and did put two (almost similar) the songs about 'Python pandas" in it. (I did this using a free version of ApowerEdit so it has a watermark.) By investing more time the video part could be improved a lot with multiple pictures and movement. I also tried Google subtitling to automatic generate a subtitle (containing the lyrics) however the result with (this) music seems poor.



I hope you enjoy hearing the audio on these two recently published videos.


Thursday, March 28, 2024

Python pandas *.csv import and export differences

As i am working on a project involving *.csv data files using the Python programming language and pandas a march 2024 blogpost about this topic. The data gets imported in Python pandas dataframes and later also saved to *.csv files. I hope to post later more details about the resulting program (I also have plans to post the final project on my GitHub)  
When checking details i noticed differences between the imported and exported data. When reading files and writing them back i immediately noticed the difference in file length. Recognizing the problem (more about them later) was not extreme difficult.

Python pandas
Python pandas

Illustration made with help of  NightCafe AI Art Creator

Solving the issue did cost more time. I wasted a lot of time with trying the solutions provided by ChatGTP, giving feedback about the problems however it did not solve my problem. By searching on internet i learned i was not the only one with the problem. However finding a solution was more difficult. In fact there where two problems in the *.csv

Missing double quotes ""

All data in the *.csv file where strings surrounded by double quotes " . When writing the *.csv file back the double quotes where gone.

Solution: When writing using the to_csv() use the option    quoting=csv.QUOTE_ALL 

NaN (or Null) values

The *.csv file contained items as "" and "None" . During reading of the data all both these values are converted to NaN in the Python panda dataframes. NaN ( in databases known as Null ) values are missing or not assigned values. 
For my project i needed to keep "" and "None" when writing back the data. Solutions provided mostly changed both values to "" or "None".  ChatGPT could not help me, however it (or he?) knew the answer.  When entered the solution that i found the response was the explanation of my solution. 

Solution: When reading using read_csv() use the option     keep_default_na=False

From the documentation on  https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html  :
By default the following values are interpreted as NaN: “ “, “#N/A”, “#N/A N/A”, “#NA”, “-1.#IND”, “-1.#QNAN”, “-NaN”, “-nan”, “1.#IND”, “1.#QNAN”, “<NA>”, “N/A”, “NA”, “NULL”, “NaN”, “None”, “n/a”, “nan”, “null “.

ChatGPT provided only solutions with the na_values options, However if keep_default_na is True, and na_values are specified, na_values is appended to the default NaN values used for parsing.

The final code

Important parts of Python ( pandas ) code used

import pandas as pd

my_import_df = pd.read_csv(csv_import_file, encoding='latin-1', keep_default_na=False, dtype=object)

my_export_df.to_csv( csv_export_file, quoting=csv.QUOTE_ALL, index=False)

Hoping to post something about my first pre-release version with some first functionalities of my project soon.

Sunday, March 17, 2024

HamVoIP via FritzBox

(This post is a dutch about HamVoIP as it is mainly of interest for Dutch Ham Radio users.)

Sinds september 2022 is het mogelijk gemaakt dat gelicenseerde radiozendamateurs elkaar contact kunnen onderhouden middels VoIP telefonie.
Dit syteem is operationeel onder de naam "HamVoIP". Ook zijn er conference bridges en een aantal radiostations die via HamVoIP beluisterd kunnen worden.
Op https://hamvoip.nl/ is hier meer info over te vinden, onder andere hoe een aanvraag voor een HamVoIP nummer gedaan kan worden. Ook staat hier info hoe dit op een aantal telefoontoestellen geconfigureerd kan worden.
Zelf het ik (PD1LAB) ook een nummer aangevraagd en gebruik dit via mijn FritzBox en hierbij mijn instellingen. (Een aantal gegevens zoals mijn wachtwoord en wat telefoonnummer cijfers heb ik onzichtbaar gemaakt.)

Ik had zelf al eerder met voip geexperimenteerd en ik heb daardoor al meerdere voip verbindingen op mijn Fritzbox.
Mijn HamVoIP verbinding was terecht gekomen op   *121#  (waarschijnlijk omdat een nummer had verwijderd en dit weer beschikbaar werd.

[ *124# is mijn normale vaste verbinding (en dit heb ik ook als default verbinding ingesteld) ]

Het invoerscherm bij aanmaken van nieuw telefoonnummer:

In eerste instantie had ik bij de gebruikersnaam mijn roepnaam ingevuld. Het bleek echter dat ook hier het telefoonnummer moest worden ingevoerd.
HamVoIP blokkeerd trouwens na 3 foute inlogpogingen gedurende 60 minuten de toegang. Daarom duurde het iets meer dan een uurtje voor mijn toegang echt werkte.  

Onderstaand de gegevens zoals zichtbaar in de FritzBox bij controle:

Bij klikken op het pennetje bij het telefoonnummer worden deze gegevens zichtbaar


 


'73 PD1LAB