'Unable to call the heroku app generated url in my local python(notebook) code

My project is a machine learning recognizing sound in surroundings. And the model is successfully deploy in Heroku. I want to call the model using the url but it is not working.

The code below is working but after i change the URL into "https://home--ear.herokuapp.com/" i get an error of: ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

URL = " http://127.0.0.1:5000/"
if __name__ == "__main__":

def audio_samples(in_data, frame_count, time_info, status_flags):
    data = np.frombuffer(in_data, dtype=np.int16) / 32768.0 
    feature = librosa.util.fix_length(data, size=22050)
    feature = librosa.feature.melspectrogram(feature, n_fft = windowLength, hop_length = hopLength, n_mels= 128)
    feature = librosa.power_to_db(feature)
    feature = (feature - np.amin(feature))/(np.amax(feature) - np.amin(feature))
    feature = np.dstack((feature,feature,feature))
    feature = feature.reshape(1,128, 101, 3)
    feature = feature.tolist()
    rms = np.sqrt(np.mean(data**2))
    dB = dbFS(rms)
    response = requests.post(URL, json={"feature":feature, "dB": dB})
    data = response.json()
    print(data)
    return (in_data, pyaudio.paContinue)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source