Invalid character in identifier…. How to solve it

File "", line 25 librosa.display.specshow(Xdb, sr=sr, x_axis=’time’, y_axis=’log’) ^ SyntaxError: invalid character in identifierputhon

import librosa

#path of the audio file

audio_data = read(NHS113.wav");

#This returns an audio time series as a numpy array with a default sampling rate(sr) of 22KHZ

x = librosa.load(audio_data, sr=None)

#We can change this behavior by resampling at sr=44.1KHz.

x = librosa.load(audio_data, sr=44000)


%matplotlib inline

import matplotlib.pyplot as plt

import librosa.display

plt.figure(figsize=(14, 5))

#plotting the sampled signal

librosa.display.waveplot(x, sr=sr)

#x: numpy array

X = librosa.stft(x)

#converting into energy levels(dB)

Xdb = librosa.amplitude_to_db(abs(X))

plt.figure(figsize=(20, 5))

librosa.display.specshow(Xdb, sr=sr, x_axis='time', y_axis='hz')


librosa.display.specshow(Xdb, sr=sr, x_axis=’time’, y_axis=’log’)

librosa.feature.mfcc(x, sr=sr

Read more here:

Content Attribution

This content was originally published by adnan zaman at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: