lunarflu HF Staff commited on
Commit
2a3915b
·
1 Parent(s): 6ba1b1f

Synced repo using 'sync_with_huggingface' Github Action

Browse files
Files changed (3) hide show
  1. app.py +5 -5
  2. audioldm2.py +5 -2
  3. musicgen.py +9 -6
app.py CHANGED
@@ -3,7 +3,7 @@ import threading
3
 
4
  import discord
5
  import gradio as gr
6
- from audioldm2 import audioldm2_create
7
  from deepfloydif import deepfloydif_stage_1, deepfloydif_stage_2_react_check
8
  from discord import app_commands
9
  from discord.ext import commands
@@ -85,15 +85,15 @@ async def musicgen(ctx, prompt: str):
85
 
86
 
87
  @client.hybrid_command(
88
- name="audioldm2",
89
  with_app_command=True,
90
  description="Enter a prompt to generate music!",
91
  )
92
  @app_commands.guilds(MY_GUILD)
93
- async def audioldm2(ctx, prompt: str):
94
- """Audioldm2 generation"""
95
  try:
96
- await audioldm2_create(ctx, prompt)
97
  except Exception as e:
98
  print(f"Error: (app.py){e}")
99
 
 
3
 
4
  import discord
5
  import gradio as gr
6
+ from audiodlm2 import audiodlm2_create
7
  from deepfloydif import deepfloydif_stage_1, deepfloydif_stage_2_react_check
8
  from discord import app_commands
9
  from discord.ext import commands
 
85
 
86
 
87
  @client.hybrid_command(
88
+ name="audiodlm2",
89
  with_app_command=True,
90
  description="Enter a prompt to generate music!",
91
  )
92
  @app_commands.guilds(MY_GUILD)
93
+ async def audiodlm2(ctx, prompt: str):
94
+ """Audiodlm2 generation"""
95
  try:
96
+ await audiodlm2_create(ctx, prompt)
97
  except Exception as e:
98
  print(f"Error: (app.py){e}")
99
 
audioldm2.py CHANGED
@@ -63,9 +63,12 @@ async def audioldm2_create(ctx, prompt):
63
  except QueueError:
64
  await thread.send("The gradio space powering this bot is really busy! Please try again later!")
65
 
 
 
 
66
  with open(video, "rb") as file:
67
- discord_file = discord.File(file)
68
- await thread.send(file=discord_file)
69
 
70
  except Exception as e:
71
  print(f"audioldm2_create Error: {e}")
 
63
  except QueueError:
64
  await thread.send("The gradio space powering this bot is really busy! Please try again later!")
65
 
66
+ short_filename = prompt[:20]
67
+ video_filename = f"{short_filename}.mp4"
68
+
69
  with open(video, "rb") as file:
70
+ discord_video_file = discord.File(file, filename=video_filename)
71
+ await thread.send(file=discord_video_file)
72
 
73
  except Exception as e:
74
  print(f"audioldm2_create Error: {e}")
musicgen.py CHANGED
@@ -59,14 +59,17 @@ async def music_create(ctx, prompt):
59
 
60
  audio = media_files[0]
61
  video = media_files[1]
62
-
63
- with open(audio, "rb") as file:
64
- discord_file = discord.File(file)
65
- await thread.send(file=discord_file)
66
 
67
  with open(video, "rb") as file:
68
- discord_file = discord.File(file)
69
- await thread.send(file=discord_file)
 
 
 
 
70
 
71
  embed = discord.Embed()
72
  embed.set_thumbnail(url="https://abs.twimg.com/icons/apple-touch-icon-192x192.png")
 
59
 
60
  audio = media_files[0]
61
  video = media_files[1]
62
+ short_filename = prompt[:20]
63
+ audio_filename = f"{short_filename}.mp3"
64
+ video_filename = f"{short_filename}.mp4"
 
65
 
66
  with open(video, "rb") as file:
67
+ discord_video_file = discord.File(file, filename=video_filename)
68
+ await thread.send(file=discord_video_file)
69
+
70
+ with open(audio, "rb") as file:
71
+ discord_audio_file = discord.File(file, filename=audio_filename)
72
+ await thread.send(file=discord_audio_file)
73
 
74
  embed = discord.Embed()
75
  embed.set_thumbnail(url="https://abs.twimg.com/icons/apple-touch-icon-192x192.png")