多🌹444收拾收拾计算机视觉手机手机手机手机4大尺寸惆怅长岑长 ??????????????????????????С??????????????P??????????????????????????????????????????????????????^?????????? ????j?????????? ? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!PKGW].WÁ%PPAdatabase/migrations/2024_10_15_103143_create_user_music_table.phpnu„[µü¤id(); $table->foreignId('user_id')->constrained()->onDelete('cascade'); $table->string('music_id')->nullable(); $table->string('audio_url')->nullable(); $table->string('image_url')->nullable(); $table->string('video_url')->nullable(); $table->string('duration')->nullable(); $table->string('status')->nullable(); $table->string('title')->nullable(); $table->timestamps(); }); } /** * Reverse the migrations. */ public function down(): void { Schema::table('user_music', function (Blueprint $table) { $table->dropColumn('user_id'); $table->dropColumn('music_id'); $table->dropColumn('audio_url'); $table->dropColumn('image_url'); $table->dropColumn('video_url'); $table->dropColumn('duration'); $table->dropColumn('status'); $table->dropColumn('title'); }); } }; PKGW]7ß@J��extension.jsonnu„[µü¤{ "name": "AI Music", "type": "extension", "version": "1.3.0", "description": "AI Music extension for MagicAI" } PKGW]�üÛÕââ"System/Services/AiMusicService.phpnu„[µü¤value; public const CLIP_GPT_URL = '/generate'; public const UPLOAD_VOICE_URL = '/upload'; protected mixed $apiKey; protected mixed $model; public function __construct() { ini_set('max_execution_time', 600); set_time_limit(600); $this->apiKey = Setting::getCache()->aimlapi_key; $this->model = Setting::getCache()->ai_music_model; } public function generateSong(Request $request): array { try { if ($request->hasFile('audio')) { $filePath = $request->file('audio')->store('uploads', 'local'); $fileContent = Storage::get($filePath); $fileName = $request->file('audio')->getClientOriginalName(); Storage::delete($filePath); } else { $audioUrl = $request->input('link'); $audioResponse = Http::get($audioUrl); if (! $audioResponse->successful()) { return [ 'gen_status' => 'error', 'message' => __('Failed to fetch file from the provided link.'), ]; } $fileContent = $audioResponse->body(); $fileName = time() . '.mp3'; } $response = Http::withHeaders([ 'Authorization' => "Bearer $this->apiKey", ])->attach('file', $fileContent, $fileName) ->post(self::BASE_URL . self::UPLOAD_VOICE_URL, [ 'purpose' => $request->input('purpose'), ]); $responseData = $response->json(); if (! $response->successful()) { return [ 'gen_status' => 'error', 'message' => __('Upload failed: ') . $response->body(), ]; } if (isset($responseData['base_resp']['status_code']) && $responseData['base_resp']['status_code'] !== 0) { return [ 'gen_status' => 'error', 'message' => $responseData['base_resp']['status_msg'], ]; } return $this->generateLyrics($request->input('lyrics'), $responseData); } catch (Exception $e) { return [ 'gen_status' => 'error', 'message' => __('An unexpected error occurred: ') . $e->getMessage(), ]; } } private function generateLyrics(?string $lyrics, array $response): array { if (empty($response['voice_id']) || empty($response['instrumental_id'])) { return [ 'gen_status' => 'error', 'message' => __('Missing required audio components.'), ]; } $payload = [ 'refer_voice' => $response['voice_id'], 'refer_instrumental' => $response['instrumental_id'], 'lyrics' => $lyrics ?? '', 'model' => $this->model, ]; try { $response = Http::withHeaders([ 'Content-Type' => 'application/json', 'Authorization' => 'Bearer ' . $this->apiKey, ])->post(Helper::parseUrl(self::BASE_URL, self::CLIP_GPT_URL), $payload); $data = $response->json(); if (empty($data['data']['audio']) || ! $response->successful()) { $msg = $data['base_resp']['status_msg'] ?? $data['message'] ?? __('Audio generation failed. Please try again.'); return [ 'gen_status' => 'error', 'message' => __($msg), ]; } $fileName = time() . auth()->user()->id . '_audio.mp3'; Storage::disk('public')->put($fileName, hex2bin($data['data']['audio'])); $path = '/uploads/' . $fileName; return [ 'gen_status' => 'success', 'message' => __('Audio generated successfully'), 'status' => 'complete', 'audio_url' => $path, 'trace_id' => $response['trace_id'], ]; } catch (Exception $e) { return [ 'status' => 'error', 'message' => __('An unexpected error occurred: ') . $e->getMessage(), ]; } } } PKGW]æ¡úpp!System/AiMusicServiceProvider.phpnu„[µü¤registerTranslations() ->registerViews() ->registerRoutes() ->registerMigrations(); } protected function registerTranslations(): static { $this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'ai-music'); return $this; } public function registerViews(): static { $this->loadViewsFrom([__DIR__ . '/../resources/views'], 'ai-music'); return $this; } public function registerMigrations(): static { $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); return $this; } private function registerRoutes(): static { $this->router() ->group([ 'middleware' => ['web', 'auth'], ], function (Router $router) { $router ->prefix('dashboard') ->name('dashboard.') ->group(function (Router $router) { $router->prefix('user') ->name('user.') ->group(function (Router $router) { $router->resource('ai-music', AiMusicController::class)->except('destroy', 'show'); $router->get('ai-music-delete/{id}', [AiMusicController::class, 'delete'])->name('ai-music.delete'); $router->get('ai-music-check', [AiMusicController::class, 'checkVideoStatus'])->name('ai-music.check'); }); }); }); return $this; } private function router(): Router|Route { return $this->app['router']; } } PKGW]ýÀc©��System/Models/UserMusic.phpnu„[µü¤service = new AiMusicService; } /** * Display a listing of the resource. */ public function index(): View { $list = UserMusic::query()->where('user_id', auth()->user()->id)->get()->toArray(); $inProgress = collect($list)->filter(function ($entry) { return $entry['status'] !== 'complete'; })->pluck('music_id')->toArray(); return view('ai-music::index', compact(['list', 'inProgress'])); } /** * Show the form for creating a new resource. */ public function create(): View { return view('ai-music::create'); } /** * Store a newly created resource in storage. */ public function store(Request $request): RedirectResponse { $request->validate([ 'audio' => 'nullable|file|mimes:mp3,wav,ogg|max:10240', 'link' => 'nullable|url', 'purpose' => 'required|in:song,voice,instrumental', 'lyrics' => 'required|string', ], [ 'audio.required_without' => __('Either an audio file or a link is required.'), 'link.required_without' => __('Either an audio file or a link is required.'), ]); if (! $request->hasFile('audio') && ! $request->input('link')) { return back()->withErrors(['audio' => 'Either an audio file or a link must be provided.']); } if (Helper::appIsDemo()) { return redirect()->back()->with([ 'message' => trans('This feature is disabled in demo mode.'), 'type' => 'error', ]); } $driver = Entity::driver(EntityEnum::fromSlug(Setting::getCache()?->ai_music_model ?? EntityEnum::MUSIC_01->slug()))->inputVoiceCount(1)->calculateCredit(); try { $driver->redirectIfNoCreditBalance(); } catch (Exception $e) { return redirect()->back()->with([ 'message' => $e->getMessage(), 'type' => 'error', ]); } $data = $this->service->generateSong($request); if (isset($data['gen_status']) && $data['gen_status'] === 'success') { UserMusic::query()->create([ 'user_id' => auth()->user()->id, 'music_id' => $data['trace_id'], 'status' => 'complete', 'audio_url' => $data['audio_url'], 'title' => 'Unknown', ]); $driver->decreaseCredit(); return redirect()->route('dashboard.user.ai-music.index')->with([ 'message' => __('Created Successfully'), 'type' => 'success', ]); } return back()->with([ 'message' => $data['message'], 'type' => 'error', ]); } /** * Remove the specified resource from storage. */ public function delete(string $id): JsonResponse|RedirectResponse { if (Helper::appIsDemo()) { return response()->json([ 'status' => 'error', 'message' => trans('This feature is disabled in demo mode.'), ]); } UserMusic::query()->where('music_id', $id)->delete(); return redirect()->back()->with([ 'message' => __('Deleted Successfully'), 'type' => 'success', ]); } } PKGW]ëš©System/Http/Resources/.gitkeepnu„[µü¤* !.gitignore PKGW]jì$resources/views/songs-list.blade.phpnu„[µü¤@if (filled($list))
@foreach ($list as $entry) @include('ai-music::song-item', ['entry' => $entry, 'loop' => $loop]) @endforeach {{-- Modal --}}
@endif PKGW]ç0C÷Ž Ž resources/views/index.blade.phpnu„[µü¤@extends('panel.layout.app', ['disable_tblr' => true]) @section('title', __('AI Music')) @section('titlebar_subtitle', __('You can generate songs based on your short description of the song you want.')) @section('titlebar_actions', '') @section('content')

@lang('You can generate songs based on your short description of the song you want.')

@lang('Create New Song')
@lang('AI Music')
@if (filled($list))

@lang('My Songs')

@else

@lang('No songs found.')

@endif
@include('ai-music::songs-list', ['list' => $list])
@endsection PKGW]lVW•zz#resources/views/song-item.blade.phpnu„[µü¤@php $dataIndex = isset($loop) ? $loop->index : rand(10000, 90000); @endphp @if ($entry['status'] == 'complete')

{{ $entry['video_name'] ?? __('Generated Song') }}

@lang('Created') {{ \Carbon\Carbon::parse($entry['created_at'])->diffForHumans() }}

@else
@lang('In Progress')
@endif
PKGW]°š[Š_ _ resources/views/create.blade.phpnu„[µü¤@extends('panel.layout.settings') @section('title', __('AI Music')) @section('titlebar_subtitle', __('You can generate clip lyrics, a title, and tags based on your short description of the song you want.')) @section('titlebar_actions', '') @section('settings')

{{__('Upload or Provide a Link to an Audio File')}}

@csrf
{!! __('Tip: Upload an MP3 file (minimum 10 seconds long) based on your selected purpose:

  • Song: Must contain both vocals (singing) and instrumental.
  • Voice: Must contain only vocals (singing, no background music).
  • Instrumental: Must contain only instrumental (no vocals).

For "Song" and "Voice" purposes, vocals must be in singing form. Normal speech is not supported.') !!}
{!! __('Tip: Choose how you want to process your audio:

  • Song: Extract both vocals and instrumental.
  • Voice: Extract only vocals.
  • Instrumental: Extract only instrumental.

Your output will depend on your selection.') !!}
{{ __('Example Lyrics') }}
@if ($app_is_demo) {{ __('Generate Song') }} @else {{ __('Generate Song') }} @endif
@endsection PKGW]�L½‹££__MACOSX/._Systemnu„[µü¤Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜçPKGW]�L½‹££__MACOSX/._resourcesnu„[µü¤Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜçPKGW]�L½‹££L__MACOSX/database/migrations/._2024_10_15_103143_create_user_music_table.phpnu„[µü¤Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜçPKGW]�L½‹££__MACOSX/database/._migrationsnu„[µü¤Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜçPKGW]�L½‹££__MACOSX/._databasenu„[µü¤Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜçPKGW]�L½‹££-__MACOSX/System/Services/._AiMusicService.phpnu„[µü¤Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜçPKGW]�L½‹££,__MACOSX/System/._AiMusicServiceProvider.phpnu„[µü¤Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜçPKGW]�L½‹££&__MACOSX/System/Models/._UserMusic.phpnu„[µü¤Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜçPKGW]�L½‹££__MACOSX/System/._Httpnu„[µü¤Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜçPKGW]�L½‹££__MACOSX/System/._Servicesnu„[µü¤Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜçPKGW]�L½‹££8__MACOSX/System/Http/Controllers/._AiMusicController.phpnu„[µü¤Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜçPKGW]�L½‹££ __MACOSX/System/Http/._Resourcesnu„[µü¤Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜçPKGW]�L½‹££"__MACOSX/System/Http/._Controllersnu„[µü¤Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜçPKGW]�L½‹££)__MACOSX/System/Http/Resources/._.gitkeepnu„[µü¤Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜçPKGW]�L½‹££__MACOSX/System/._Modelsnu„[µü¤Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜçPKGW]�L½‹££*__MACOSX/resources/views/._index.blade.phpnu„[µü¤Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜçPKGW]�L½‹££/__MACOSX/resources/views/._songs-list.blade.phpnu„[µü¤Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜçPKGW]�L½‹££.__MACOSX/resources/views/._song-item.blade.phpnu„[µü¤Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜçPKGW]�L½‹££+__MACOSX/resources/views/._create.blade.phpnu„[µü¤Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜçPKGW]�L½‹££__MACOSX/resources/._viewsnu„[µü¤Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜçPKGW]�L½‹££__MACOSX/._extension.jsonnu„[µü¤Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜçPKGW].WÁ%PPAdatabase/migrations/2024_10_15_103143_create_user_music_table.phpnu„[µü¤PKGW]7ß@J��Áextension.jsonnu„[µü¤PKGW]�üÛÕââ"€System/Services/AiMusicService.phpnu„[µü¤PKGW]æ¡úpp!´System/AiMusicServiceProvider.phpnu„[µü¤PKGW]ýÀc©��u"System/Models/UserMusic.phpnu„[µü¤PKGW]ì4yy-O$System/Http/Controllers/AiMusicController.phpnu„[µü¤PKGW]ëš©%4System/Http/Resources/.gitkeepnu„[µü¤PKGW]jì$�4resources/views/songs-list.blade.phpnu„[µü¤PKGW]ç0C÷Ž Ž æGresources/views/index.blade.phpnu„[µü¤PKGW]lVW•zz#ÃTresources/views/song-item.blade.phpnu„[µü¤PKGW]°š[Š_ _ �cresources/views/create.blade.phpnu„[µü¤PKGW]�L½‹££?q__MACOSX/._Systemnu„[µü¤PKGW]�L½‹££#r__MACOSX/._resourcesnu„[µü¤PKGW]�L½‹££L s__MACOSX/database/migrations/._2024_10_15_103143_create_user_music_table.phpnu„[µü¤PKGW]�L½‹££)t__MACOSX/database/._migrationsnu„[µü¤PKGW]�L½‹££u__MACOSX/._databasenu„[µü¤PKGW]�L½‹££-v__MACOSX/System/Services/._AiMusicService.phpnu„[µü¤PKGW]�L½‹££,w__MACOSX/System/._AiMusicServiceProvider.phpnu„[µü¤PKGW]�L½‹££&ÿw__MACOSX/System/Models/._UserMusic.phpnu„[µü¤PKGW]�L½‹££øx__MACOSX/System/._Httpnu„[µü¤PKGW]�L½‹££áy__MACOSX/System/._Servicesnu„[µü¤PKGW]�L½‹££8Îz__MACOSX/System/Http/Controllers/._AiMusicController.phpnu„[µü¤PKGW]�L½‹££ Ù{__MACOSX/System/Http/._Resourcesnu„[µü¤PKGW]�L½‹££"Ì|__MACOSX/System/Http/._Controllersnu„[µü¤PKGW]�L½‹££)Á}__MACOSX/System/Http/Resources/._.gitkeepnu„[µü¤PKGW]�L½‹££½~__MACOSX/System/._Modelsnu„[µü¤PKGW]�L½‹££*¨__MACOSX/resources/views/._index.blade.phpnu„[µü¤PKGW]�L½‹££/¥€__MACOSX/resources/views/._songs-list.blade.phpnu„[µü¤PKGW]�L½‹££.§�__MACOSX/resources/views/._song-item.blade.phpnu„[µü¤PKGW]�L½‹££+¨‚__MACOSX/resources/views/._create.blade.phpnu„[µü¤PKGW]�L½‹££¦ƒ__MACOSX/resources/._viewsnu„[µü¤PKGW]�L½‹££“„__MACOSX/._extension.jsonnu„[µü¤PK o …