Integration-Automation / ReEdgeGPT

Microsoft's Bing Chat AI
MIT License
163 stars 27 forks source link

Suno mp4 file #124

Closed FuseFairy closed 7 months ago

FuseFairy commented 9 months ago

when using suno, it's possible return mp4 file or download link?

JE-Chen commented 9 months ago

When I try to access the song link. image Maybe it’s not possible? They call too many JavaScript functions to generate the song.

FuseFairy commented 9 months ago

I can probably understand how the whole repo works, and it would be nice to have a function like image generation, but it should be quite difficult. Thank you for your hard work!

FuseFairy commented 8 months ago

Perhaps could take a look at this? https://github.com/juzeon/SydneyQt/blob/e0f082952811ce0e0eaad1afda666a994fdab2ca/sydney/music.go#L27 image

JE-Chen commented 7 months ago

I finally completed this feature, example code.

import asyncio
import json
from pathlib import Path

from re_edge_gpt import Chatbot
from re_edge_gpt import ConversationStyle
from re_edge_gpt.plugins.suno import generate_suno_music

# If you are using jupyter pls install this package
# from nest_asyncio import apply

async def test_ask() -> None:
    bot = None
    try:
        cookies: list[dict] = json.loads(open(
            str(Path(str(Path.cwd()) + "/bing_cookies.json")), encoding="utf-8").read())
        bot = await Chatbot.create(cookies=cookies, mode="Bing", plugin_ids=["suno"])
        prompt = """Can you create some epic music"""
        response = await bot.ask(
            prompt=prompt,
            conversation_style=ConversationStyle.balanced,
            simplify_response=True,
            add_options=["014CB21D"],
            plugins=[{"Id": "c310c353-b9f0-4d76-ab0d-1dd5e979cf68", "Category": 1}],
            message_type="GenerateContentQuery"
        )
        # If you are using non ascii char you need set ensure_ascii=False
        print(json.dumps(response, indent=2, ensure_ascii=False))
        print(await generate_suno_music(cookies, response.get("messageId"), response.get("requestId")))
    except Exception as error:
        raise error
    finally:
        if bot is not None:
            await bot.close()

if __name__ == "__main__":
    # If you are using jupyter pls use nest_asyncio apply()
    # apply()
    try:
        loop = asyncio.get_running_loop()
    except RuntimeError:
        loop = asyncio.get_event_loop()
    loop.run_until_complete(test_ask())

Output:

{
  "requestId": "####",
  "text": "Certainly! 🎵 Here's an epic musical snippet for you:\n\n```markdown\n[Verse]\nRoaring through the darkness\nBattles of the past\nWarriors united\nUntil the very last\nWe rise and we fall\nBut we'll never give in\nIn this **epic symphony**\nThe story begins\n\nStorms of emotion\nThunder in our hearts\nWe march to the beat\nTearing worlds apart\nWith every step we take\nA legend unfolds\nIn this **epic melody**\nOur destiny unfolds\n```\n\nFeel the grandeur, the clash of swords, and the surge of emotions as our heroes embark on their epic journey! 🌟✨\n\nYour full song will be available shortly. You can also create more songs on [Suno.ai](https://app.suno.ai). 🎶 \n [Verse]\nRoaring through the darkness\nBattles of the past\nWarriors united\nUntil the very last\nWe rise and we fall\nBut we'll never give in\nIn this epic symphony\nThe story begins\n\nStorms of emotion\nThunder in our hearts\nWe march to the beat\nTearing worlds apart\nWith every step we take\nA legend unfolds\nIn this epic melody\nOur destiny unfolds",
  "author": "bot",
  "source_keys": [],
  "source_values": [],
  "suggestions": [
    "Continue the song!",
    "Tell me a story about these warriors.",
    "Can you create an epic poem?"
  ],
  "image_create_text": "",
  "messages_left": 30,
  "max_messages": 30,
  "messageId": "####"
}
{'Image': 'https://th.bing.com/th?&id=OIG3.i_0435cf4d81634b83955f8d90e31f7bcc', 'Audio': 'https://th.bing.com/th?&id=OIG3.a_0435cf4d81634b83955f8d90e31f7bcc', 'Video': 'https://th.bing.com/th?&id=OIG3.v_0435cf4d81634b83955f8d90e31f7bcc', 'Duration': 'https://th.bing.com/th?&id=60.0', 'Style': 'https://th.bing.com/th?&id=grand cinematic orchestral', 'Title': 'https://th.bing.com/th?&id=Epic Melodies', 'Lyrics': "https://th.bing.com/th?&id=[Verse]\nRoaring through the darkness\nBattles of the past\nWarriors united\nUntil the very last\nWe rise and we fall\nBut we'll never give in\nIn this epic symphony\nThe story begins\n\nStorms of emotion\nThunder in our hearts\nWe march to the beat\nTearing worlds apart\nWith every step we take\nA legend unfolds\nIn this epic melody\nOur destiny unfolds"}
JE-Chen commented 7 months ago

Should be used in the next version.

FuseFairy commented 7 months ago

look perfect~ I look forward to it.

JE-Chen commented 7 months ago

Now you can use generate_suno_music to get a Suno song. Notice that only when simplify_response=True, you can obtain the messageId and requestId on response. If simplify_response=False, you’ll need to retrieve raw response to get the messageId and requestId.

        response = await bot.ask(
            prompt=prompt,
            conversation_style=ConversationStyle.balanced,
            simplify_response=True,
            add_options=["014CB21D"],
            plugins=[{"Id": "c310c353-b9f0-4d76-ab0d-1dd5e979cf68", "Category": 1}],
            message_type="GenerateContentQuery"
        )

        print(await generate_suno_music(cookies, response.get("messageId"), response.get("requestId")))
FuseFairy commented 7 months ago

work perfect! image