Skip to content

Instantly share code, notes, and snippets.

@nwatab
nwatab / warehouse_step1.py
Last active August 7, 2023 07:37
荷物運び (倉庫番)ゲーム
# 関数を使わず書きます
# 改行関係のない40文字.
# o: 荷物
# O: ゴールの上の荷物
# p: プレイヤー
# P: ゴールの上のプレイヤー
# .: ゴール
# #: 壁
soko = \
@nwatab
nwatab / init.el
Created June 22, 2022 08:59
.emacs.d/init.el
;;; init.el --- My init.el -*- lexical-binding: t; -*-
;; Copyright (C) 2020 Naoya Yamashita
;; Author: Naoya Yamashita <conao3@gmail.com>
;; 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.
@nwatab
nwatab / tensorflow-2-4-1-has-an-issue-in-metrics-calculation.ipynb
Created February 22, 2021 16:20
Tensorflow 2.4.1 has an issue in metrics calculation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nwatab
nwatab / App.tsx
Last active January 15, 2021 03:16
ReactJS + Firebase + Basic Authentication (ベーシック認証)
import React from 'react';
import { BrowserRouter as Router, Switch, Route} from "react-router-dom";
import Users from './Users';
export default function App() {
return (
<Router>
<Switch>
<Route exact path="/users/:id">
<Users />
@nwatab
nwatab / index.html
Last active November 25, 2020 02:58
Plot bird observations in Japan on google map
<!DOCTYPE html>
<html>
<head>
<title>Add Map</title>
<script src="./positions.js" defer></script>
<script
src="https://maps.googleapis.com/maps/api/js?key=GOOGLE_MAP_JS_API_KEY&callback=initMap&libraries=&v=weekly"
defer
></script>
<style type="text/css">
@nwatab
nwatab / dump.py
Created November 19, 2020 06:26
save firestore collections
import os
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
cred = credentials.Certificate('../your_project_credential.json')
firebase_admin.initialize_app(cred, {
'projectId': 'your_project_id'
})
@nwatab
nwatab / comparison_melspectrogram.ipynb
Last active November 10, 2020 04:11
Comparison log mel spctrogram of librosa and tensorflowI/O
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nwatab
nwatab / README.md
Last active September 27, 2020 06:13
Load mp3 data efficiently (Tensorflow==2.3.0)

Comparison

  • Read 4 batchs of 10 audio signals sequentially without converting into spectrogram via numpy (code not shown in this gist): 30.084 sec
  • Read 4 batchs of 10 audio signals and convert into dB mel spectrograms via tf.data.Dataset sequentially without optimization: 9.423 sec
  • Read 4 batchs of 10 audio signals and convert into dB mel spectrograms via tf.data.Dataset with optimization: 3.922sec

References

  1. https://www.tensorflow.org/guide/data_performance
  2. https://www.tensorflow.org/io/tutorials/audio
@nwatab
nwatab / App.tsx
Last active February 18, 2021 15:43
Firebase Authentication sample signin, signup and email verification. SignUp code is complicated and I want to refactor.
import React from 'react';
import { BrowserRouter as Router, Route, Switch} from 'react-router-dom'
import { ThemeProvider } from '@material-ui/styles';
import {Elements} from '@stripe/react-stripe-js';
import {loadStripe} from '@stripe/stripe-js';
import theme from './Theme'
import { AuthProvider } from './Auth'
import SignUp from './SignUp'
import tensorflow as tf
class LogMelspectrogramLayer(tf.keras.layers.Layer):
"""
signals = librosa.load('path/to/audio.mp3')
log_melspectrogram_layer = LogMelspectrogramLayer()
logmelspectrogram = log_melspectrogram_layer(signals)
"""
def __init__(self, num_fft=2048, hop_length=512, sr=24000, fmin=125., fmax=3800., num_mel=128, **kwargs):
super(LogMelgramLayer, self).__init__(**kwargs)