Skip to content

Instantly share code, notes, and snippets.

print(len("✋"))
print(len("✋🏾"))
print(len("👪"))
print(len("👨‍👨‍👧‍👦"))
print(len("👨‍👧‍👦"))
print(len("👨‍👦"))
@gustheman
gustheman / magics_test.py
Last active January 19, 2022 17:13
magics_test.py
print('this is Python file to test some magics')
def my_function(a, b, c):
print(a, b, c)
return a + b + c
@gustheman
gustheman / ploting_answers.py
Last active October 15, 2022 22:21
This is a simple function to plot results from the Kaggle Kernel Survey (2021 and 2022). It will work only on multiple choise questions
import pandas as pd
import numpy as np
import plotly.express as px
df = pd.read_csv("kaggle_survey_2022_responses.csv")
def plot_answers(data, question_prefix, year):
filter_columns = [col for col in data.columns if col.startswith(question_prefix)]
df = data[filter_columns]
@gustheman
gustheman / plot_waves.py
Created March 8, 2023 14:28
Generating wave graphs in python
import matplotlib.pyplot as plt
import numpy as np
plt.figure(figsize=(14,10))
def show_frequency(x, y, i):
plt.subplot(3, 1, i)
plt.stem(x, y, 'r', use_line_collection=True)
plt.plot(x, y)
plt.xlabel("time")
@gustheman
gustheman / tf_load_audio.py
Created March 8, 2023 15:34
TF to load an audio file
!pip install -q "tensorflow_io==0.28.*"
!curl -O https://storage.googleapis.com/audioset/miaow_16k.wav
import tensorflow as tf
import tensorflow_io as tfio
from IPython.display import Audio
audio = tfio.audio.AudioIOTensor('miaow_16k.wav')
@gustheman
gustheman / plot_frequency.py
Created March 8, 2023 15:42
Plotting frequencies
import matplotlib.pyplot as plt
import tensorflow as tf
n = len(x)
T = 1/samples
yf = tf.signal.fft(ys)
xf = np.linspace(0.0, 1.0/(2.0*T), int(n/2))
plt.plot(xf, 2.0/n*np.abs(yf[:n//2]))
@gustheman
gustheman / build_spectrogram.py
Created March 8, 2023 15:51
Creates a spectrogram based on a waveform
import tensorflow as tf
import tensorflow_io as tfio
tensor = tf.cast(audio_tensor, tf.float32) / 32768.0
spectrogram = tfio.audio.spectrogram(
tensor, nfft=512, window=512, stride=256)
mel_spectrogram= tfio.audio.melscale(
spectrogram, rate=16000, mels=128, fmin=0, fmax=8000)