i get this error in hugging face model to link frontent of my code?today 11 clock my completetion please help clear this error

#29
by GanesanSuresh - opened

127.0.0.1 - - [11/Apr/2024 09:46:42] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [11/Apr/2024 09:46:43] "GET /static/script.js HTTP/1.1" 304 -
127.0.0.1 - - [11/Apr/2024 09:46:43] "GET /static/style.css HTTP/1.1" 304 -
127.0.0.1 - - [11/Apr/2024 09:46:52] "POST /generate_music HTTP/1.1" 500 -
Traceback (most recent call last):
File "C:\Users\prasa\OneDrive\Desktop\your project\venv\Lib\site-packages\flask\app.py", line 1488, in call
return self.wsgi_app(environ, start_response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\prasa\OneDrive\Desktop\your project\venv\Lib\site-packages\flask\app.py", line 1466, in wsgi_app
response = self.handle_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\prasa\OneDrive\Desktop\your project\venv\Lib\site-packages\flask\app.py", line 1463, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\prasa\OneDrive\Desktop\your project\venv\Lib\site-packages\flask\app.py", line 872, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\prasa\OneDrive\Desktop\your project\venv\Lib\site-packages\flask\app.py", line 870, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\prasa\OneDrive\Desktop\your project\venv\Lib\site-packages\flask\app.py", line 855, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\prasa\OneDrive\Desktop\your project\venv\my project\app.py", line 29, in generate_music_route
music = generate_music_pipeline(input_text)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\prasa\OneDrive\Desktop\your project\venv\my project\app.py", line 39, in generate_music_pipeline
music = synthesiser(input_text, max_new_tokens=256)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\prasa\OneDrive\Desktop\your project\venv\Lib\site-packages\transformers\pipelines\text_to_audio.py", line 182, in call
return super().call(text_inputs, **forward_params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\prasa\OneDrive\Desktop\your project\venv\Lib\site-packages\transformers\pipelines\base.py", line 1158, in call
preprocess_params, forward_params, postprocess_params = self._sanitize_parameters(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: TextToAudioPipeline._sanitize_parameters() got an unexpected keyword argument 'max_new_tokens'
this my error
code is below:
from flask import Flask, render_template, request, jsonify, send_file
import csv
from transformers import pipeline
import numpy as np
import os
import tempfile
from scipy.io import wavfile

app = Flask(name)

Initialize the synthesizer pipeline

synthesiser = pipeline("text-to-audio", model="facebook/musicgen-small")

Load emoji descriptions

def load_emoji_descriptions(csv_file_path):
emoji_to_description = {}
with open(csv_file_path, mode='r', encoding='utf-8') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
emoji_to_description[row['Emoji(s)']] = row['Description']
return emoji_to_description

emoji_to_description = load_emoji_descriptions(r"C:\Users\prasa\OneDrive\Desktop\your project\venv\my project\emojis.csv")

@app .route('/generate_music', methods=['POST'])
def generate_music_route():
data = request.get_json()
input_text = data['inputText']
music = generate_music_pipeline(input_text)
# Save the audio to a temporary file
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.wav')
wavfile.write(temp_file.name, rate=music["sampling_rate"], data=music["audio"].numpy())
temp_file.close()
return send_file(temp_file.name, as_attachment=True, attachment_filename='music.wav')

def generate_music_pipeline(input_text):
# Use the synthesizer pipeline to generate music without specifying max_new_tokens
# Assuming synthesiser is your text-to-audio pipeline
music = synthesiser(input_text, max_new_tokens=256)

return music

@app .route('/')
def index():
return render_template('index.html')

if name == "main":
app.run(debug=True)

GanesanSuresh changed discussion status to closed
GanesanSuresh changed discussion status to open
GanesanSuresh changed discussion title from i get this in hugging face model to link frontent of my code?today 11 clock my completetion please help clear this error to i get this error in hugging face model to link frontent of my code?today 11 clock my completetion please help clear this error

Sign up or log in to comment