Spaces:
Build error
Build error
| from transformers import AutoProcessor, BarkModel | |
| import torch | |
| import scipy.io.wavfile | |
| # Load model and processor | |
| processor = AutoProcessor.from_pretrained("suno/bark") | |
| model = BarkModel.from_pretrained("suno/bark") | |
| # Input text | |
| text = "Hello! This is Bark speaking from Hugging Face." | |
| # Prepare inputs | |
| inputs = processor(text, return_tensors="pt") | |
| # Generate audio | |
| with torch.no_grad(): | |
| audio = model.generate(**inputs) | |
| # Save the waveform | |
| audio = audio.cpu().numpy().squeeze() | |
| scipy.io.wavfile.write("bark_output.wav", rate=22050, data=audio) | |