Skip to content

Instantly share code, notes, and snippets.

@nwatab
nwatab / init.el
Created Jun 22, 2022
.emacs.d/init.el
View 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 Feb 22, 2021
Tensorflow 2.4.1 has an issue in metrics calculation
View tensorflow-2-4-1-has-an-issue-in-metrics-calculation.ipynb
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 Jan 15, 2021
ReactJS + Firebase + Basic Authentication (ベーシック認証)
View App.tsx
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 Nov 25, 2020
Plot bird observations in Japan on google map
View index.html
<!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 Nov 19, 2020
save firestore collections
View dump.py
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 Nov 10, 2020
Comparison log mel spctrogram of librosa and tensorflowI/O
View comparison_melspectrogram.ipynb
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 Sep 27, 2020
Load mp3 data efficiently (Tensorflow==2.3.0)
View README.md

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 Feb 18, 2021
Firebase Authentication sample signin, signup and email verification. SignUp code is complicated and I want to refactor.
View App.tsx
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'
View log_melspectrogram.py
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)