Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -28,6 +28,7 @@ import matplotlib.pyplot as plt
|
|
| 28 |
from matplotlib.animation import FuncAnimation
|
| 29 |
import base64
|
| 30 |
from io import BytesIO
|
|
|
|
| 31 |
|
| 32 |
# Load the emotion prediction model
|
| 33 |
def load_emotion_model(model_path):
|
|
@@ -426,6 +427,40 @@ def add_360_metadata(img):
|
|
| 426 |
|
| 427 |
|
| 428 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 429 |
def create_360_viewer_html(image_paths, audio_paths, output_path):
|
| 430 |
"""Create an HTML file with a 360 viewer and audio player for the given images and audio."""
|
| 431 |
# Create a list of image data URIs
|
|
@@ -579,10 +614,10 @@ def create_360_viewer_html(image_paths, audio_paths, output_path):
|
|
| 579 |
|
| 580 |
if (audioFiles[index]) {{
|
| 581 |
audioPlayer.src = audioFiles[index];
|
| 582 |
-
audioInfo.textContent =
|
| 583 |
// Try to play automatically (may be blocked by browser policies)
|
| 584 |
audioPlayer.play().catch(e => {{
|
| 585 |
-
audioInfo.textContent =
|
| 586 |
}});
|
| 587 |
}} else {{
|
| 588 |
audioPlayer.src = '';
|
|
@@ -633,13 +668,13 @@ def create_360_viewer_html(image_paths, audio_paths, output_path):
|
|
| 633 |
<div id="panorama"></div>
|
| 634 |
<div id="audio-controls">
|
| 635 |
<audio id="audio-player" controls></audio>
|
| 636 |
-
<div id="audio-info">Audio for Chunk {parseInt(selectedIndex) + 1}</div>
|
| 637 |
</div>
|
| 638 |
<script src="https://cdn.jsdelivr.net/npm/pannellum@2.5.6/build/pannellum.js"><\/script>
|
| 639 |
<script>
|
| 640 |
pannellum.viewer('panorama', {{
|
| 641 |
"type": "equirectangular",
|
| 642 |
-
"panorama": "{images[selectedIndex]}",
|
| 643 |
"autoLoad": true,
|
| 644 |
"autoRotate": -2,
|
| 645 |
"showZoomCtrl": true,
|
|
@@ -648,8 +683,8 @@ def create_360_viewer_html(image_paths, audio_paths, output_path):
|
|
| 648 |
}});
|
| 649 |
|
| 650 |
const audioPlayer = document.getElementById('audio-player');
|
| 651 |
-
if ("{audioFiles[selectedIndex]}") {{
|
| 652 |
-
audioPlayer.src = "{audioFiles[selectedIndex]}";
|
| 653 |
audioPlayer.play().catch(e => {{
|
| 654 |
document.getElementById('audio-info').textContent = 'Click play to listen to audio';
|
| 655 |
}});
|
|
@@ -673,6 +708,8 @@ def create_360_viewer_html(image_paths, audio_paths, output_path):
|
|
| 673 |
return output_path
|
| 674 |
|
| 675 |
|
|
|
|
|
|
|
| 676 |
# Replace the create_fade_transition function with this updated version
|
| 677 |
def create_fade_transition(images, fade_duration=1.0, fps=24):
|
| 678 |
"""
|
|
|
|
| 28 |
from matplotlib.animation import FuncAnimation
|
| 29 |
import base64
|
| 30 |
from io import BytesIO
|
| 31 |
+
import struct
|
| 32 |
|
| 33 |
# Load the emotion prediction model
|
| 34 |
def load_emotion_model(model_path):
|
|
|
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
+
import gradio as gr
|
| 431 |
+
import pyvista as pv
|
| 432 |
+
from pyvista import examples
|
| 433 |
+
import numpy as np
|
| 434 |
+
import librosa
|
| 435 |
+
import requests
|
| 436 |
+
from io import BytesIO
|
| 437 |
+
from PIL import Image
|
| 438 |
+
import os
|
| 439 |
+
from tensorflow.keras.models import load_model
|
| 440 |
+
from faster_whisper import WhisperModel
|
| 441 |
+
import random
|
| 442 |
+
from textblob import TextBlob
|
| 443 |
+
import torch
|
| 444 |
+
import scipy.io.wavfile
|
| 445 |
+
from transformers import AutoProcessor, MusicgenForConditionalGeneration
|
| 446 |
+
import tempfile
|
| 447 |
+
import base64
|
| 448 |
+
import plotly.graph_objects as go
|
| 449 |
+
from plotly.subplots import make_subplots
|
| 450 |
+
import soundfile as sf
|
| 451 |
+
from pydub import AudioSegment
|
| 452 |
+
import math
|
| 453 |
+
import json
|
| 454 |
+
import imageio
|
| 455 |
+
from PIL import Image, ImageFilter
|
| 456 |
+
import matplotlib.pyplot as plt
|
| 457 |
+
from matplotlib.animation import FuncAnimation
|
| 458 |
+
import base64
|
| 459 |
+
from io import BytesIO
|
| 460 |
+
import struct # Added missing import
|
| 461 |
+
|
| 462 |
+
# ... (rest of your imports and code remains the same)
|
| 463 |
+
|
| 464 |
def create_360_viewer_html(image_paths, audio_paths, output_path):
|
| 465 |
"""Create an HTML file with a 360 viewer and audio player for the given images and audio."""
|
| 466 |
# Create a list of image data URIs
|
|
|
|
| 614 |
|
| 615 |
if (audioFiles[index]) {{
|
| 616 |
audioPlayer.src = audioFiles[index];
|
| 617 |
+
audioInfo.textContent = 'Playing audio for Chunk ' + (index + 1);
|
| 618 |
// Try to play automatically (may be blocked by browser policies)
|
| 619 |
audioPlayer.play().catch(e => {{
|
| 620 |
+
audioInfo.textContent = 'Click play to listen to audio for Chunk ' + (index + 1);
|
| 621 |
}});
|
| 622 |
}} else {{
|
| 623 |
audioPlayer.src = '';
|
|
|
|
| 668 |
<div id="panorama"></div>
|
| 669 |
<div id="audio-controls">
|
| 670 |
<audio id="audio-player" controls></audio>
|
| 671 |
+
<div id="audio-info">Audio for Chunk ${parseInt(selectedIndex) + 1}</div>
|
| 672 |
</div>
|
| 673 |
<script src="https://cdn.jsdelivr.net/npm/pannellum@2.5.6/build/pannellum.js"><\/script>
|
| 674 |
<script>
|
| 675 |
pannellum.viewer('panorama', {{
|
| 676 |
"type": "equirectangular",
|
| 677 |
+
"panorama": "${{images[selectedIndex]}}",
|
| 678 |
"autoLoad": true,
|
| 679 |
"autoRotate": -2,
|
| 680 |
"showZoomCtrl": true,
|
|
|
|
| 683 |
}});
|
| 684 |
|
| 685 |
const audioPlayer = document.getElementById('audio-player');
|
| 686 |
+
if ("${{audioFiles[selectedIndex]}}") {{
|
| 687 |
+
audioPlayer.src = "${{audioFiles[selectedIndex]}}";
|
| 688 |
audioPlayer.play().catch(e => {{
|
| 689 |
document.getElementById('audio-info').textContent = 'Click play to listen to audio';
|
| 690 |
}});
|
|
|
|
| 708 |
return output_path
|
| 709 |
|
| 710 |
|
| 711 |
+
|
| 712 |
+
|
| 713 |
# Replace the create_fade_transition function with this updated version
|
| 714 |
def create_fade_transition(images, fade_duration=1.0, fps=24):
|
| 715 |
"""
|