Skip to content

Instantly share code, notes, and snippets.

@tam17aki
tam17aki / phase-frequency-comparison.py
Last active November 5, 2024 13:05
位相スペクトルの時間方向の差分と arctan経由の時間微分(瞬時周波数)の比較を行うPythonコード
import japanize_matplotlib
import matplotlib.pyplot as plt
import numpy as np
from scipy import signal
# パラメータ設定
fs = 1000 # サンプリング周波数
t = np.arange(0, 1, 1 / fs) # 時間軸
f0 = 5 # 基本周波数
f1 = 10 # 周波数変調の上限
import cv2
import librosa
import numpy as np
import soundfile as sf
from scipy import signal
from scipy.io import wavfile
class AudioSteganography:
"""音声信号への画像埋め込みと復元."""
"""Demonstration script of voice chatbot."""
import os
import google.generativeai as genai
def main():
"""Perform chat with Gemini."""
genai.configure(api_key=os.environ["GEMINI_API_KEY"])
@tam17aki
tam17aki / ratiofunc.py
Last active October 23, 2024 21:50
Demonstration script for phase recovery via rational function approximation.
# -*- coding: utf-8 -*-
"""Demonstration script for phase recovery via rational function approximation.
Copyright (C) 2024 by Akira TAMAMORI
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
[tool.pyright]
typeCheckingMode = "standard"
[tool.mypy]
strict = false
ignore_missing_imports = true
[tool.ruff]
# Exclude a variety of commonly ignored directories.
exclude = [
@tam17aki
tam17aki / ruff-sort-imports.el
Created June 29, 2024 07:23
Sort the order of imports in Python source code by using Ruff.
;;; ruff-sort-imports.el --- Sort import libraries of Python source via Ruff -*- lexical-binding: t; -*-
;; Copyright (C) 2024 Akira Tamamori
;; Copyright (C) 2023 Ville Skyttä
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
@tam17aki
tam17aki / phaseret_demo.py
Last active June 13, 2024 12:41
Demonstration script of phase reconstruction with PHASRET and oct2py.
# -*- coding: utf-8 -*-
"""Demonstration script of phase reconstruction with PHASRET and oct2py.
Copyright (C) 2024 by Akira TAMAMORI
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
import numpy as np
import soundfile as sf
from oct2py import octave
from scipy import signal
WIN_LEN = 512
HOP_LEN = 128
FFT_LEN = 512
WINDOW = "hann"
IN_WAV = "ONOMATOPEE300_001.wav"
@tam17aki
tam17aki / GLU.py
Last active April 29, 2024 06:15
"Wrapper modules of PyTorch GLU.
# -*- coding: utf-8 -*-
"""Wrapper modules of Gated Linear Unit (GLU).
Copyright (C) 2024 by Akira TAMAMORI
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
#!/usr/bin/env python3
# MIT License
# Copyright (C) 2024 by Akira TAMAMORI
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
# (the Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,