extra prints
This commit is contained in:
		
							
								
								
									
										7
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								main.py
									
									
									
									
									
								
							| @@ -149,13 +149,17 @@ class MusicView(discord.ui.View): | ||||
|  | ||||
|  | ||||
| async def send_tts_message(message: str, channel: discord.TextChannel): | ||||
| 	print("saving tts to file...") | ||||
| 	tts_engine.save_to_file(message, "voice-message.mp3") | ||||
| 	tts_engine.runAndWait() | ||||
| 	await send_voice_message("voice-message.mp3", channel) | ||||
| 	print("cleaning up...") | ||||
| 	if os.path.exists("voice-message.mp3"): os.remove("voice-message.mp3") | ||||
|  | ||||
| async def send_voice_message(file_path: str, channel: discord.TextChannel): | ||||
| 	bot_token = os.getenv('TOKEN') | ||||
|  | ||||
| 	print("converting to ogg...") | ||||
| 	# Convert MP3 to OGG (Opus) using ffmpeg | ||||
| 	ogg_filename = "voice-message.ogg" | ||||
| 	try: | ||||
| @@ -182,6 +186,7 @@ async def send_voice_message(file_path: str, channel: discord.TextChannel): | ||||
| 		duration, waveform = get_audio_metadata(ogg_filename) | ||||
| 		file_size = os.path.getsize(ogg_filename) | ||||
|  | ||||
| 		print("getting upload url...") | ||||
| 		# Step 1: Request an upload URL | ||||
| 		url = f"https://discord.com/api/v10/channels/{channel.id}/attachments" | ||||
| 		headers = { | ||||
| @@ -206,6 +211,7 @@ async def send_voice_message(file_path: str, channel: discord.TextChannel): | ||||
| 		upload_url = upload_data["upload_url"] | ||||
| 		uploaded_filename = upload_data["upload_filename"] | ||||
|  | ||||
| 		print("uploading...") | ||||
| 		# Step 2: Upload the audio file | ||||
| 		with open(ogg_filename, "rb") as file: | ||||
| 			upload_response = requests.put(upload_url, headers={"Content-Type": "audio/ogg"}, data=file) | ||||
| @@ -214,6 +220,7 @@ async def send_voice_message(file_path: str, channel: discord.TextChannel): | ||||
| 			print("Failed to upload file:", upload_response.text) | ||||
| 			exit() | ||||
|  | ||||
| 		print("sending voice message...") | ||||
| 		# Step 3: Send the voice message | ||||
| 		message_url = f"https://discord.com/api/v10/channels/{channel.id}/messages" | ||||
| 		message_payload = { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 SpookyDervish
					SpookyDervish