Explore all Audio open source software, libraries, packages, source code, cloud functions and APIs.

Explore Related Topics

Popular New Releases in Audio

howler.js

v2.2.3

fingerprintjs

v3.3.3

Tone.js

14.7.39

BackgroundMusic

0.4.0-SNAPSHOT-b38f6dd

AudioKit

AudioKit 5.3.1

Popular Libraries in Audio

howler.js

by goldfire doticonjavascriptdoticon

star image 18632 doticonMIT

Javascript audio library for the modern web.

fingerprintjs

by fingerprintjs doticontypescriptdoticon

star image 16423 doticonMIT

Browser fingerprinting library with the highest accuracy and stability.

UnblockNeteaseMusic

by nondanee doticonjavascriptdoticon

star image 14911 doticonMIT

Revive unavailable songs for Netease Cloud Music

Tone.js

by Tonejs doticontypescriptdoticon

star image 11634 doticonMIT

A Web Audio framework for making interactive music in the browser.

BackgroundMusic

by kyleneideck doticonc++doticon

star image 11173 doticonNOASSERTION

Background Music, a macOS audio utility: automatically pause your music, set individual apps' volumes and record system audio.

AudioKit

by AudioKit doticonswiftdoticon

star image 9080 doticonMIT

Swift audio synthesis, processing, & analysis platform for iOS, macOS and tvOS

sonic-pi

by sonic-pi-net doticonc++doticon

star image 8904 doticonNOASSERTION

Code. Music. Live.

nuclear

by nukeop doticontypescriptdoticon

star image 8707 doticonAGPL-3.0

Streaming music player that finds free music for you

ieaseMusic

by trazyn doticonjavascriptdoticon

star image 8524 doticonMIT

网易云音乐第三方

Trending New libraries in Audio

NoiseTorch

by lawl doticoncdoticon

star image 6018 doticonNOASSERTION

Real-time microphone noise suppression on Linux.

pedalboard

by spotify doticonc++doticon

star image 3250 doticonGPL-3.0

🎛 🔊 A Python library for manipulating audio.

ddsp

by magenta doticonpythondoticon

star image 2125 doticonApache-2.0

DDSP: Differentiable Digital Signal Processing

spot

by xou816 doticonrustdoticon

star image 1399 doticonMIT

Native Spotify client for the GNOME desktop

SDRPlusPlus

by AlexandreRouma doticonc++doticon

star image 1288 doticonGPL-3.0

Cross-Platform SDR Software

omnizart

by Music-and-Culture-Technology-Lab doticonpythondoticon

star image 1128 doticonMIT

Omniscient Mozart, being able to transcribe everything in the music, including vocal, drum, chord, beat, instruments, and more.

GiantMIDI-Piano

by bytedance doticonpythondoticon

star image 856 doticon

ggwave

by ggerganov doticonc++doticon

star image 768 doticonMIT

Tiny data-over-sound library

lyrebird

by lyrebird-voice-changer doticonpythondoticon

star image 695 doticonMIT

🦜 Simple and powerful voice changer for Linux, written in GTK 3.

Top Authors in Audio

1

mohayonao

38 Libraries

star icon1095

2

keijiro

31 Libraries

star icon3202

3

mmckegg

23 Libraries

star icon1136

4

danigb

18 Libraries

star icon475

5

jazz-soft

16 Libraries

star icon544

6

jpcima

16 Libraries

star icon455

7

atsushieno

16 Libraries

star icon261

8

x42

15 Libraries

star icon352

9

AudioKit

14 Libraries

star icon11200

10

arirusso

14 Libraries

star icon535

1

38 Libraries

star icon1095

2

31 Libraries

star icon3202

3

23 Libraries

star icon1136

4

18 Libraries

star icon475

5

16 Libraries

star icon544

6

16 Libraries

star icon455

7

16 Libraries

star icon261

8

15 Libraries

star icon352

9

14 Libraries

star icon11200

10

14 Libraries

star icon535

Trending Kits in Audio

Flappy Bird is an arcade-style game. It was initially released as a mobile game while tapping the screen to make the bird fly. Later, the game's pc version was released, where the Bird will be controlled using the up key or the space bar. If Bird hits on the pipes or the screen edges, the game ends, and the player needs to restart. Flappy Bird can fly the Bird as far as you can without hitting a pipe. The player is tasked with navigating Faby through pairs of pipes with equally sized gaps placed at random heights. Try to play as long as possible, score as many points as you can!. Following are the steps to be followed for build Flappy Bird Game, 1. Graphics Setup 2. Game Logic 3. Creating Input Controls 4. Generating Sound effects & Display Scores 5. Multi-player

Multi-player

Flappy bird is a single-player game, but it's possible to have multiplayer by using below libraries. Players will play on their game field one who gets more scores will win the game.

Graphic Designs & Game logic

Graphic designs are used in a flappy game to build an image of the player (bird), background, pipe, base and for displaying messages. Game logic and Graphic designs are build by using below libraries.

Creating Input Controls

Key mapper is an open-source library that allows users to use a key or combination of keys to perform a specific action(fly), which can be used for navigating.

Sound effects & Scores

Sound effects are used while the bird hits the pipe, generating scores for every move of a bird and a Game over by sfb & FlapPyBird libraries . Using flairfly library, scores can be calculated by the number of pipes crossed.

Pinball is an arcade game where a player uses paddles to launch the ball into the table. It prevents the ball from falling past your flippers if possible. 


Interact with dynamic elements of the table like blockers, bumpers, flippers, gates, holes, LEDs, plungers, rollovers, slingshots, spinners, targets, ramps, and pipes to increase your score and get multipliers. This game comes with three balls. Use the arrow keys to hit the left or right flippers. Following are the steps to be followed to build Your Pinball Game, 1. Graphic designs 2. Sound effects 3. User Interface 4. Pinball controller 5. Leaderboard 6. 3D Pinball game

Graphic Designs

Listed below libraries help in creating the best graphic design for gaming applications, which is used in design tables and infrastructure in pinball.

User Interface

The below user interface libraries are used for different platforms like android, Pc.

Sound effects

Sound effects are used for ball hitting, dropping, paddles, and also starting & ending of the game. These effects can be achieved by using the below libraries.

Pinball Controller

The below libraries are used to control the spring to start, left and right paddles to prevent ball drop.

Leaderboard

The below libraries are used to display scores, the history of the player, player name. It has a database connection to save the scores and create a leaderboard.

3D Pinball Game

The pinball game can be built in 3D by using the below library.

As we are in the digital era, real-time video games are ruling the young generation. Tank games are one of the addictive games of this generation.


The objective of this game is to destroy the enemy's tank with our tank, which will decrease the energy level of the opponent. Similarly, our energy level will be reduced when the opponent attacks us with their tank. The attacking capacity ultimately depends on the energy level. The more is the energy level, the high is the attacking capacity. Following are the steps to be followed for building Tank Fight Game, 1.Graphic design & Sound effects 2.Firing and exploiting the tanks 3.Customize control over keyboard 4.Multi-player 5.3D Tank game

Customize control over keyboard

Key mapper is an open-source library that allows users to use a key or combination of keys to perform a specific action, which can be used for navigating and shooting. The below libraries can help you to create your control.

Graphic design & Sound effects

Listed below libraries help in creating the best graphic design and sound effects for gaming applications using python, C#, JavaScript, which can be used to design tanks, animate the movement of tanks, explosion of tanks, and display energy level bars.

Firing and exploiting the tanks

Random module, an open-source library, generates a random number provided the range, which can be used for firing and exploiting the tanks, decides the playing turn at the start of every game.

3D Tank game

The tank game can be built in 3D by using the below library.

Multi-player

Tank game can be played as multiplayer by using the below libraries. Multiplayers will play on the game field they shoot each other. The more is the energy level. The high is the attacking capacity.


Generative artificial intelligence (AI) describes algorithms that help in creating/generating new content, including audio, code, images, text and videos.


In this kit, we build a Music generator from Text and Audio prompts using the Meta's MusicGen model. Meta's Audiocraft research team has released MusicGen, an open source deep learning language model that can generate new music based on text prompts and even be aligned to an existing song.


MusicGen is a single stage auto-regressive Transformer model capable of generating high-quality music samples conditioned on text descriptions or audio prompts. The text descriptions are passed through a frozen text encoder model to obtain a sequence of hidden-state representations. MusicGen is then trained to predict discrete audio tokens, or audio codes, conditioned on these hidden states. These audio tokens are then decoded using an audio compression model, such as EnCodec, to recover the audio waveform.


MusicGen has been trained on 20000 hours of licensed music. MusicGen is exceptional in its capacity to handle both text and musical cues, in addition to the effectiveness of the design and the speed of creation. The text establishes the fundamental style, which the audio file’s music subsequently follows.

Libraries used in this solution


Development Environment


VSCode and Jupyter Notebook are used for development and debugging. Jupyter Notebook is a web based interactive environment often used for experiments, whereas VSCode is used to get a typical experience of IDE for developers.


Jupyter Notebook is used for our development.

Artificial Intelligence


AI libraries and frameworks here are helpful in providing state-of-the-art solutions using AI

Kit Solution Source

UI app Integration

Support


For any support, you can reach us at OpenWeaver Community Support

kandi 1-Click Install

Due to its low level and high performance, C++ is a popular programming language for audio apps. Audio is being employed in various applications, like video games, voice recognition, virtual & augmented reality, and music & movie production. To include high-quality audio in apps, developers need access to reliable and extensive audio libraries with various features and capabilities.  


C++ audio libraries allow developers to create highly individualized and specialized solutions for a wide range of applications thanks to their elevated level of customization and flexibility. Developers can create platforms and devices thanks to these libraries, which are typically cross-platform and compatible with numerous operating systems.  


Here is a list of the seven best C++ Audio Libraries for 2023: 

JUCE

  • Helps in developing a cross-platform music production or audio engineering tool. 
  • Helps in building a custom GUI interface for an existing audio application or plugin. 
  • Helps in creating a custom digital instrument or synthesizer with advanced signal processing and modulation capabilities. 
  • Helps develop a custom audio effects processor or filter with advanced parameter controls. 
  • Helps in building a custom audio analysis or visualization tool with real-time data processing. .

OpenAL-Soft

  • Helps in developing a video game with spatial audio effects. 
  • Helps in building an augmented reality or virtual reality application with immersive soundscapes. 
  • Helps in creating a navigation or mapping application that uses audio cues to provide directions. 
  • Helps in building a speech recognition or natural language processing application that uses spatial audio to improve accuracy. 
  • Helps develop a sonification application that converts data into sound for auditory analysis. 

RtAudio

  • Helps develop a custom audio streaming or processing application with low latency requirements. 
  • Helps in building a custom driver or interface for specialized audio hardware. 
  • Helps in creating a custom audio recorder or playback application with advanced data processing or analysis features. 
  • Helps in implementing a custom audio protocol or format for specialized applications. 
  • Helps develop a custom software synthesizer or instrument plugin with advanced processing and modulation features. 

FlexASIO

  • Helps in building a digital audio workstation or music production software. 
  • Helps in developing an audio recording and playback application. 
  • Helps in creating a custom sound effect or virtual instrument plugin. 
  • Helps in implementing a voice chat or video-conferencing application. 
  • Helps in building a machine learning model that uses audio data for training.  

libSDL2pp

  • Helps in developing a simple soundboard or media player application. 
  • Helps in building a basic karaoke or sing-along application. 
  • Helps in developing a voice recording and editing application. 
  • Helps in creating an educational tool that uses audio for language learning or pronunciation training. 
  • Helps in building a sound analysis or signal-processing tool for research or scientific purposes. 

FMOD-for-unreal

  • Helps in building a video game with complex audio mixing and effects. 
  • Helps develop a music streaming or podcast application with advanced audio processing features.  
  • Helps implement a sound design or audio production workflow with high flexibility and customization. 
  • Helps in creating an interactive installation or exhibit that uses sound as a key component. 
  • Helps in building a virtual instrument or synthesizer plugin with advanced DSP features. 

ofxFFT

  • Helps in building a custom audio analysis or visualization tool with frequency analysis capabilities. 
  • Helps develop a custom audio processing or filtering tool with Fourier transform features. 
  • Helps in implementing a custom audio encoding or decoding algorithm with advanced processing capabilities. 
  • Helps develop a custom audio synthesis or signal generator with frequency modulation features. 
  • Helps build a custom audio compression or decompression algorithm with spectral analysis capabilities

JavaScript audio player libraries support many formats, like MP3, WAV, and OGG. This versatility ensures compatibility across various browsers and devices. It allows developers to provide their users with a seamless audio playback experience.  


These libraries offer an array of features for audio playback. The features include playback speed adjustment, looping capabilities, and volume control. These features empower developers to create interactive and customized audio player interfaces.  


Following best practices for playing audio files is important when using this library. They help Understand the code and library configuration and implement error handling to ensure smooth playback. Customization options can enhance and integrate the player's appearance into the design.  

We can use JavaScript audio player libraries in various web development scenarios. We can employ it in creating audio players for websites, allowing users to play and control. Furthermore, we can leverage it to develop more complex audio player applications. It helps with applications like music streaming platforms or interactive web games.  


We recommend selecting audio files to make the most of a JavaScript audio player library. We should choose the optimized ones for playback, balancing size, and audio quality. Additionally, integrating the library can expand its capabilities. It provides a more robust audio player solution.  

When writing about these libraries, we must cover their historical significance. We should cover its ability to play audio files, features, and customization options. We should understand their versatility in scenarios and the benefits of integrating them.  


JavaScript audio player libraries provide seamless audio playback, enabling interactive features. It supports its versatility, browser compatibility, and extensive feature aim to deliver high-quality audio experiences. It helps in enhancing user engagement.  

howler.js:  

  • This library helps in creating interactive audio players in JavaScript.  
  • It supports playing and pausing audio and controlling volume. It supports seeking specific positions and handling audio events.  
  • It provides a robust foundation for building custom audio player interfaces.  

plyr:  

  • This library is a versatile media player that supports audio and video playback.  
  • It supports play/pause, seeking, volume control, and fullscreen mode. It provides a complete solution for media playback.  
  • It helps in creating customizable audio players with a sleek and modern interface.  

Tone.js:  

  • This library focuses on audio synthesis and processing in JavaScript.  
  • It helps create dynamic and interactive audio players. It helps make it suitable for music composition, sound design, and game development.  
  • It supports various audio effects, MIDI integration, and precise timing control.  

wavesurfer.js:  

  • This library supports audio waveform visualization and playback in JavaScript.  
  • It helps create audio players with waveform displays. It allows visualization and interaction with the audio.  
  • It supports features like zooming, scrolling, and highlighting specific waveform sections. It helps in enhancing the user experience.  

SoundJS:  

  • This library is part of the CreateJS suite. It provides a powerful audio playback solution for web applications.  
  • It supports audio preloading and playback control. It also supports HTML5 audio elements and Web Audio API integration.  
  • It helps create interactive players with audio playback and synchronization across many sounds.

jPlayer:  

  • This library provides a versatile audio player solution for HTML and JavaScript.  
  • It helps in creating cross-browser-compatible audio players with customizable skins and themes. 
  • It supports various formats, playlist management, and repeat, shuffle, and volume control features. It helps in catering to different audio playback requirements.  

react-soundplayer:

  • This library is specifically designed for building audio players in React applications.  
  • It supports features like play/pause, volume control, and seeking. It provides a user-friendly interface for audio playback.  
  • It integrates well with React's component-based architecture. It supports customization through props and callbacks.  

buzz:  

  • This lightweight audio library helps in simple audio playback scenarios.  
  • It supports audio player features like play, pause, volume control, and event handling.  
  • It is easy to use, making it suitable for audio players without complex customization.  

FAQ 

1. What is the most beautiful HTML5 music player?  

The beauty of an HTML5 music player is subjective. It can vary based on personal preferences and design choices. The choice depends on the UI design, animations, color schemes, and aesthetics. Many visually appealing HTML5 music player implementations are available.  

  

2. How does JavaScript Audio Player work in modern browsers?  

JavaScript Audio Player leverages the capabilities through the Web Audio API & HTML5 element. In modern browsers, these APIs provide a robust foundation for audio playback. It allows developers to control playback and adjust the volume. It helps handle events and apply audio effects and filters.  

  

3. What are the features of a custom audio player library?  

Custom audio player libraries offer various features to enhance the audio playback experience. These features include play/pause, next/previous track navigation, and volume control. It includes seeking within the audio, looping, and playlist management. It includes visualization effects, equalizer settings, and integration with other media platforms.  

  

4. How lightweight is the JavaScript library for creating an HTML5 audio/video player?  

JavaScript libraries for creating HTML5 audio/video players prioritize lightweight implementations. They design these libraries to minimize file size and external dependencies. It helps ensure optimal performance and fast loading times. It results in efficient and streamlined code that does not add unnecessary bloat to the web page.  

  

5. Are specific playback controls necessary to create an HTML5 video player?  

HTML5 video players need specific playback controls to provide a seamless user experience. Common controls include play or pause buttons, volume controls, and progress bars. It also includes fullscreen mode and options for adjusting playback speed. We can customize the controls and their appearance based on the needs and design.  

  

6. Can modern browsers handle a play button that triggers audio content on requests?  

Modern browsers can handle a play button that triggers audio content on requests. JavaScript code can initiate the playback when the user interacts with a play button. We can do so by playing the <audio> element or creating and playing audio using the Web Audio API. Modern browsers support such interactions, ensuring a smooth and responsive audio playback experience. 

Here are some famous JavaScript Audio Player Libraries. Some of the use cases of JavaScript Audio Player Libraries include Creating custom music players for streaming platforms, Adding audio effects to games, Creating interactive audio applications, Creating audio visualizers, Creating audio synthesizers, and Creating soundscapes.  


Javascript audio player libraries are collections of code that allow developers to create and integrate audio players into a web page. These libraries typically contain functions for loading audio, playing and pausing tracks, adjusting the volume, and more. They can also create custom audio players with unique features and designs. 


Let us have a look at the libraries in detail. 

plyr

  • Includes many customization options.
  • Compatible with the latest versions of all major browsers.
  • Fully responsive and scaled to any device or screen size. 

howler.js

  • Support for Web Audio 3D spatial audio.
  • Supports all popular audio formats, including MP3, AAC, OGG, and WAV.
  • Allows you to create multiple audio channels. 

DPlayer

  • Responsive and has built-in support for scaling to different screen sizes.
  • Supports a wide range of customization options.
  • Supports playback across multiple platforms

mediaelement

  • Compatible with all major web browsers.
  • Supports both HTML5 and Flash audio playback on mobile devices.
  • Comes with lots of pre-built components, such as a playlist. 

APlayer

  • Lightweight and powerful library with a modern design
  • Supports multiple audio sources, such as local files, remote URLs, and streaming audio.
  • Offers a powerful API for developers

SoundManager2

  • Works with Flash 8, allowing for reliable audio playback on older browsers.
  • Highly configurable, allowing for a range of audio playback options.
  • Supports HTML5 audio fallback.

jPlayer

  • Flexible options for styling and customizing the player.
  • Wide range of API support for customizing functionality.
  • A unique data-attribute feature allows custom data to be passed to the player. 

amplitudejs

  • Designed to be responsive to any size viewport.
  • Allows developers to create multiple playlists.
  • Features a powerful and customizable UI.

green-audio-player

  • Can be easily modified with custom CSS.
  • Mobile-friendly and supports touch gestures. 
  • Can be integrated easily with any web page. 

Here are the best open-source Python sound-processing libraries for your applications. You can use them to build web and smartphone applications with audio analysis, synthesis, and manipulation functions.


These libraries provide powerful tools for sound processing in Python, such as reading and writing sound files, support for a wide range of file formats, and more with a simple and efficient interface for loading and saving audio data. With these libraries, developers get a wide range of tools for audio analysis, including feature extraction, segmentation, and representation, along with support for loading and saving various audio file formats. These Python libraries also support various audio formats, allowing developers to perform tasks such as cutting, concatenating, and exporting audio files. These open-source coding components are widely used in music information retrieval and audio signal processing research.


We have handpicked top and trending open-source Python sound-processing libraries for your next project. They offer a variety of easy-to-use interfaces for manipulating and processing audio files.

Librosa:

  • Used for music and audio analysis.
  • Offers features for beat tracking, melody extraction, and sound decomposition.
  • Supports Linux, Mac, and Windows operating systems.

SoundFile:

  • Used for reading and writing audio files.
  • Supports a wide range of formats and sample rates.
  • Based on libsndfile, CFFI, and NumPy libraries.

Pydub:

  • Used for working with audio as a sequence of frames.
  • Offers features like playback, mixing, and processing.
  • Provides a simple and easy high-level interface for audio manipulation and processing.

PySoundCard

  • Used for accessing sound card hardware.
  • Features include audio input and output and control of audio parameters.
  • Can play and record audio data as well.
  • Based on PortAudio, CFFI, and NumPy libraries.

Madmom:

  • Used for music and audio analysis, signal processing, etc.
  • Features include beat tracking, chord recognition, and onset detection algorithms.
  • Has a strong focus on music information retrieval (MIR) tasks.

music21:

  • Used for music theory, analysis, and composition.
  • Capabilities include capabilities for parsing, editing, and generating musical scores.
  • Offers a toolkit for Computer-Aided Musical Analysis and Computational Musicology.

Aubio:

  • Used for real-time audio signal processing.
  • Features include pitch detection, onset detection, and beat-tracking algorithms.
  • Allows audio labeling: pitch, onset, tempo tracking, and more.

Audio:

  • Used for data manipulation and transformation for audio signal processing.
  • Supports multiple audio input formats.
  • Based on PyTorch library.

Redux itself is a predictable state container for JavaScript applications. It focused on predictably managing the application state through reducers.


Redux doesn't have built-in support for managing side effects like playing sounds. 


Integrating sound effects with Redux: 


  1. Middleware: It can use middleware like Redux Thunk and Redux Saga. Redux Observable is a tool used to manage asynchronous actions and side effects in Redux applications. These middleware solutions are not designed for managing sound effects. It can use them to trigger sound playback in response to Redux actions. 
  2. Action Creators: It can create action creators that dispatch actions to trigger sound. These action creators can be called from components. The middleware is in response to certain application events or state changes. 
  3. Separate Sound Library: It is a standalone sound library like Howler.js or Tone.js. These libraries provide powerful audio management capabilities. It can be used in conjunction with Redux by dispatching Redux actions. To control sound playback based on application state changes. 
  4. Component Integration: It can integrate sound playback into React components. This can dispatch Redux actions from React components to trigger sound effects. It can be using HTML5 audio elements or third-party audio libraries. 
  5. Custom Middleware: It can create custom middleware tailored to handle sound effects. This middleware can intercept certain Redux actions. It can trigger sound playback based on predefined mappings or logic. 


Overall, while Redux itself doesn't handle sound effects. It can integrate sound playback into Redux applications using middleware. It can be custom logic or separate sound libraries in conjunction with Redux actions. Redux itself doesn't have built-in support for sound effects. It can use middleware or plugins to manage side effects like playing sounds. 

sound-redux: 

  • Sound-redux is a library designed to ease the management of audio within Redux. 
  • Sound-redux enables developers to integrate sound effects, music, or other audio elements. 
  • sound-redux simplifies the integration of audio functionality into Redux applications. 


howler.js: 

  • Howler.js is designed to work seamlessly across different web browsers. 
  • Howler.js is a popular JavaScript library that simplifies the implementation of audio. 
  • Howler.js supports multiple audio formats such as MP3, AAC, OGG, WAV, and WebM. 


react-native-sound: 

  • React-native-sound is a library designed for handling audio playback in React Native applications. 
  • React native sound is compatible with both iOS and Android platforms. 
  • React-native-sound supports a wide range of audio formats commonly used in mobile applications. 


Tone.js: 

  • Tone.js is a comprehensive Web Audio framework for creating interactive music experiences. 
  • Tone.js offers a wide range of audio synthesis and processing capabilities. 
  • Tone.js offers high-level abstractions for creating musical sequences, patterns, and rhythms. 


quiet-js: 

  • Quiet.js is a JavaScript library designed for transmitting data via waves through the Web Audio API. 
  • Quiet.js enables the transmission of data through audio signals. 
  • Quiet.js uses Frequency Shift Keying modulation techniques to encode digital into audio. 


chrome-music-lab: 

  • Chrome Music Lab is a web-based platform that allows users to explore music and sound. 
  • Chrome Music Lab is accessible through any web browser that supports the modern web. 
  • Chrome Music Lab includes features to make music creation and exploration accessible. 


web-audio-api: 

  • The Web Audio API is a powerful JavaScript API for processing and synthesizing audio in web apps. 
  • The Web Audio API supports various audio sources, including audio files. 
  • The API provides a wide range of audio processing nodes, each serving a purpose in the audio graph. 


redux-thunk:

  • Redux Thunk is a middleware for Redux's predictable state container for JavaScript apps. 
  • It allows you to write action creators that return a function instead of an action object. 
  • Redux Thunk enables you to handle asynchronous logic in Redux actions. 


redux-observable: 

  • Redux Observable embraces reactive programming principles. 
  • It allows developers to model and manage asynchronous actions as streams of events. 
  • Redux Observable provides built-in support for the cancellation and debouncing of asynchronous operations. 


FAQ


1.What are Redux libraries for sound effects? 

Redux libraries for sound effects are middleware, plugins, or integrations. It helps to design to ease the management and playback of sound effects within Redux apps. 


2.Why use Redux libraries for sound effects? 

Redux libraries provide a structured and predictable way to manage sound playback. That can give a response to application state changes or user interactions. They ensure that sound effects are integrated into the application's state management system. 


3.How do Redux libraries for sound effects work? 

Redux libraries for sound effects provide middleware or utilities that intercept Redux actions. It triggers sound playback based on predefined mappings or logic. They allow developers to define sound effects and control playback parameters. This integrates sound management into Redux state management. 


4.Can Redux libraries for sound effects handle asynchronous operations? 

Yes, many Redux libraries for sound effects support asynchronous operations. It such loading audio files, playing sound effects, and handling error conditions. Middleware solutions like redux-saga or redux-thunk can be used to manage asynchronous behavior. 


5. Are Redux libraries for sound effects suitable for all types of applications? 

Redux libraries for sound effects are suitable for a wide range of applications. It includes games, multimedia applications, interactive websites, and educational platforms. They provide a flexible and scalable solution for integrating sound into Redux apps.  

React audio players come in distinct varieties, each with unique features and capabilities. Here are a few well-liked choices:  

  • React Audio Player is a straightforward and compact audio player for React. It offers fundamental functions like play, pause, and volume control.  
  • This audio player component, React Sound Player, provides a more feature-rich experience. It provides seeking, volume control, playlist capabilities, and UI customization.  

React Player:   

Although it was created for playing back videos, it supports audio files too. These features include:  

  • Playback controls.  
  • UI customization choices.  
  • Compatibility for different media formats.  
  • Options for adjusting playback speed and quality.  

Howler:   

Howler is a potent web audio library that works well with React. Streaming, crossfading, looping, and spatial audio effects are some playback features it supports.  

 

React Wavesurfer library combines React with Wavesurfer.js audio visualization library. It provides controls for playing, customization options, and waveform visualization.  

 

These are only a few of the React audio players offered for sale. Your project's needs will determine the audio player you choose. These needs include desired functionality, customizability choices, and compatibility with other libraries.  

 

React audio players provide several functionalities to improve audio playback in web applications.  

 

Basic playback controls include the functions of play, pause, stop, and seek. This allows users to manage the playback of audio files.  

 

Users can change the audio playback's volume with volume controls, like sliders, & buttons.  

 

Changing the playback speed enables users to listen to sounds at a faster or slower tempo.  

 

Looping:  

When an audio file has this feature, it can play back until it is manually stopped.  

 

Support for playlists:  

Some audio players offer playlist features for continuous playback of audio files.  

 

File Format Support:   

React audio players support formats like MP3, WAV, OGG, and AAC for playing many audios.  

 

Customizable UI:   

Many audio players offer choices for altering the player's user interface (UI). This includes color schemes, layouts, and styles, to go in with the look and feel of the program.  

 

Visualization:   

Audio players offer visualization features to give a visual representation of the audio. These can be waveform visualizations, equalizer displays, and more.  

 

Support for streaming audio files:   

Some audio players can replay live or loaded audio content. Thanks to their support for streaming audio files.  

 

Crossfading:   

When switching between songs in a playlist, crossfading technology makes seamless transitions.  

 

React audio players can be divided depending on their features and integration potential. React audio players come in the following types:  

 

Standalone Audio Players:   

These are independent audio player components created especially for React applications. They offer all the capabilities required for audio playback without any extra dependencies. This can include controls, volume control, and playlist support.  

 

Media Players That Can Be Integrated:   

Some React audio players can be connected to external media services or libraries. They offer a React wrapper for media players like Video.js or Plyr. It makes it possible to combine audio and video playback.  

 

React audio players can be categorized based on their capabilities and integration potential. Some types of reacting audio players include:  

 

Independent audio player components designed for React applications are standalone audio players. They provide the necessary features for audio playback. These include controls, volume control, and playlist support without other dependencies.  

 

Integrative Media Players:  

Some React audio players support tying into external media services or repositories. Integrate audio & video playback using React wrapper for media players - Video.js or Plyr.  

 

Thus, developers prefer React audio players for adding audio playback to React applications. They offer unique features & leverage the flexibility and extensibility of the React framework.  

react-native-audio-player:   

  • These libraries are employed in music streaming applications.  
  • They enable users to play, pause, skip tracks, and control the playback of music files.  
  • These libraries include functionality for smooth streaming, playlist control, and audio visualization.  
  • Podcast apps can use these libraries to provide functionalities.  
  • These include episode selection, playback controls, and bookmarking while they listen to podcasts.  
  • These libraries may also offer the ability to download episodes for offline listening.  
  • Language learning apps can use these libraries to play audio. It includes pronunciation aids, conversations, and vocabulary drills.  
  • They enable users to manage playback when listening to audio recordings.  

react-jPlayer:   

  • Developers can use this library to build custom media players.  
  • It supports essential features such as play, pause, volume control, and playlist functionality.  
  • It provides an extensible framework for implementing audio & video playback in React apps.  
  • It incorporates the jPlayer plugin, ensuring consistent playback across various devices and browsers.  
  • It offers robust support for a wide range of platforms and browsers.  
  • Developers create responsive media players using this library.  
  • It can change its size and orientation to fit any screen. This is very helpful for building responsive or mobile-friendly web applications.  

react-wavy-audio:   

  • Use this library to see the audio waveform of songs or music tracks.  
  • Users' audio navigation and visual experiences can be enhanced.  
  • This library can build podcast players that allow users to view the audio's waveform.  
  • Users benefit from a visual guide to help them recognize the parts of the podcast program.  
  • In audio editing software, we can use this library.  
  • It helps to view and interact with the waveform representation of the audio file. This makes it possible to select, cut, and manipulate audio parts.  

howler.js:  

  • Advanced capabilities are available for playing and controlling audio files in various formats.  
  • Include interactive audio features like music players, soundboards, and games.  
  • Create audio visualizations that can playback to give audiovisual representations.  
  • Streaming services, local files, URLs, and other audio sources can all be loaded and played.  
  • For custom logic and user feedback, handle audio events. It includes playback progress, completion, and faults.  
  • Create immersive 3D audio worlds by utilizing spatial audio characteristics.  

Tone.js:  

  • You can create musical applications by synthesizing and sequencing audio. You can do so by using various integrated audio modules and effects.  
  • Use generative music systems and interactive music visualizations.  
  • Real-time audio parameter control allows for expressive performances and dynamic audio manipulation.  
  • Sync audio playback with images, animations, or outside events to synchronize multimedia.  
  • Create your own bespoke audio signal routing and audio effects, processors.  
  • MIDI input and output can be integrated with MIDI controllers and equipment.  

wavesurfer.js:  

  • Visualize audio waveforms with a waveform player that is interactive and customizable.  
  • Implement tools for audio editing, including cropping, zooming, and region selection.  
  • Make tools for audio annotation so that you can mark audio tracks.  
  • Convert spoken words into text by creating audio transcription tools.  
  • Include audio analysis tools like beat detection or audio fingerprinting.  
  • Create audio players with unique UI components and playback controls.  

soundmanager-rails:  

  • Play audio files with fallback help for many browsers and operating systems.  
  • Simple controls are used to control audio playing.  
  • Use audio streaming to playback lengthy audio files or audio streams continuously.  
  • Make your audio playlists with navigation and many tracks.  
  • To create custom logic or user interactions, add audio event callbacks.  
  • Ensure powerful audio capabilities, including audio sprites, pan control, and custom DSP effects.  

FAQ:   

1. What is the best video player library for a React project?   

A popular video player library for React projects is React Player. It offers comprehensive features, including:  

  • support for various video formats,  
  • customizable UI,  
  • playback controls, and  
  • advanced options like playback speed & quality control.  

React Player is used and well-maintained, with a large community update. This makes it a reliable choice for integrating video playback into React applications.  

 

2. How does the Web Audio API work for audio players?   

Audio decoding:   

The API enables the decoding and processing of audio files. This allows audio players to play a variety of formats, including MP3, WAV, or OGG.  

Playing Control:   

The API provides fine control over audio playing. This helps audio players to regulate and modify playback behavior. Features include play, pause, seek, and volume adjustment.  

Audio Effects:   

API provides built-in audio processing nodes for equalization, reverb, and filtering effects. Thus, it will enhance the sound output of audio players.  

 

3. What are the advantages of using a React component in my audio player library?   

Component-Based Architecture:   

This is a component-based architecture of React. It decomposes the functionality of your music player into more manageable, reusable components. Modularity promotes code reuse and scalability, simplifying code comprehension, maintenance, and updates.  

The efficiency of the virtual DOM:   

Only the relevant changed components are updated and rendered using React's virtual DOM. This improves user experience by decreasing pointless DOM interactions and speeding up rendering. Thus, it will optimize performance in your music player library.  

 

React has a wealth of third-party libraries, tools, and resources. Find and use pre-existing music player components, state management solutions, and UI libraries. This helps in reducing development time by leveraging established resources.  

 

4. Can my audio player library include any child components?   

Yes, a library of audio players can have many child components. It helps offer a comprehensive and feature-rich solution. You can take into account the following typical elements:  

User interaction with audio playing is made possible by player control elements. The control elements like play, pause, stop, next, previous, and volume control buttons.  

Progress Bar:  

A progress bar component. It lets users navigate to a specified point in the audio track. It helps graphically display the current playback position.  

Time Display:  

The time display informs users of the status of playback. It shows the current time and length of the audio track.  

Playlist:  

You can include a playlist component. It will help manage and browse through audio tracks. It happens if your audio player library supports playlists. 

Support

  1. For any support on kandi solution kits, please use the chat
  2. For further learning resources, visit the Open Weaver Community learning page.

Build your own Smash Battle video game application by using these open-source libraries and components.


Smash Battle is a cross and 2D platform shooter. It is an 8-bit style game where two, three, or four players face off against everyone. This game is inspired by the Mario battle mini game from Mario 3. Since first development it had changed a lot over time. And the gamers as well as developers have contributed a lot to it.


There are 20 characters to choose from in the game, with different statistics, 20 different stages, and fire bullets, bombs, and airstrikes at your enemies or push the player into a pit. We can also add features to this game like music, voice commands, and background.


Explore the below mentioned list of open-source libraries and components to build a Smash Battle video game for fun:

Smash battle game

Smash Battle game is a cross and 2D platform shooter.

Music

Music to accompany the dialogue or action of a motion picture in the game.

Background Image

This is the part of the design which helps the players to get attract with the game.

Voice Command

It allows the player to command and interact with others through speech.

Nowadays, using Ruby Music Player libraries like Black_Candy, Slack_DJ, Ruby_mpd and mpd_client is a common practice among music lovers. These libraries allow us to play music from our favorite artists or songs from our favorite albums in our application. The Ruby Music Player library provides a complete Ruby interface to the MPD music player. It allows you to play audio files and manage your music collection with a familiar interface. Black_Candy - Black_Candy is the most popular music player library in Ruby. It has support for streaming audio from HTTP sources and radio stations. It also has an extendable plugin system that allows users to create their own plugins as well as customize existing ones by adding new high-level methods and classes, or extending existing ones with new low-level data types and functions. Black_Candy is a light-weight MPD client for the Ruby programming language. It's built on top of libmpdclient and uses Sinatra for routing and integration with Rails views. Slack_DJ - Slack DJ is a Ruby gem for playing music streams from Slack channels in your own application. The library was written by @slackbot, so it's 100% free and open source software. Ruby MPD client is a pure Ruby implementation of the MPD protocol, built on top of libmpd. mpd_client is an embedded MPD client for use in embedded projects. The following is a comprehensive list of the best open source Ruby Music Player libraries

The use of JavaScript Music Player libraries like APlayer, Groovebasin, Volumio2, Stretto and others has become more popular due to the popularity of the browser-based music player. It's easy to use and can be customized easily with various plugins. The JavaScript based players are great because they allow you to play music while working on other tasks such as browsing the web, or editing documents. The main advantage of using JavaScript MP library is that it allows you to create custom players for your websites and apps based on your needs. The APlayer is a music player for Android. It plays your music stored on your Android phone or tablet, as well as online playlists from the web. The Groovebasin is an open source music player for Android. It allows you to play music stored on your Android device and online radio stations, as well as stream music over the Internet. The Volumio2 is an open source Linux-based OS for streaming audio from one or more USB turntables directly to your HiFi system, using either USB or Ethernet connections. The Stretto JavaScript Music Player library lets you control Stretto players via JavaScript API, which allows for easy integration with web applications and websites. The following is a list of the most popular open source JavaScript Music Player libraries

The best way to start playing music on your PC is to use a C# music player library. The most popular and powerful ones are Dopamine-windows, BreadPlayer, gMusic and Meridian. These libraries are designed to be used in Windows Vista or later. They all use the same core API, but each one offers its own user interface and features. The most important part of these libraries is that they allow you to play any type of file format without having to install additional codecs or software. You can play everything from MP3s to OGGs with them! There are many C# music player libraries out there that you can use in your next project. Some of them require you to spend a lot of time and effort on building a custom UI while others are very simple and easy to use. Dopamine-windows is a free, open-source library that can be used in any Windows application. It supports all the common file formats and codecs, as well as streaming audio. BreadPlayer library is an alternative to the popular VLC media player. It was developed by the folks at Google, so you know it's well. GMusic library offers support for various audio players, including Winamp and Windows Media Player. Full list of the best open source C# music player libraries are below

Python Music Player libraries like FeelUOwn, Quodlibet, TauonMusicBox, Python-mpd2 are basically a wrapper around the mpd protocol. Each provides a slightly different interface for playing music from your local server or streaming audio from the internet. You can use them to play your own music files (you'll have to convert them to MP3 format) or stream online music from sites like Spotify, SoundCloud and YouTube. FeelUOwn is focused on playing music stored on your own computer - so you can use it to play any songs you have stored in your iTunes library. FeelUOwn is a lightweight, easy to use Python library for playing music with the MPD (Music Player Daemon) server. Quodlibet is focused on playing music stored on other people's computers - so you can use it to play any songs they've uploaded to their own websites. Quodlibet is a music player/library written in Python which works with the Music Player Daemon (MPD). Quodlibet supports many features such as album art fetching and tag editing. TauonMusicBox is focused on playing music played by other people (or vice versa). It is an open source library for playing music from various sources. Python-mpd2 is a fork of the original MPD2 music player written in Python. It has been rewritten from scratch to be much more intuitive and user friendly, with a focus on music discovery. Check out the list of free, open source Python Music Player libraries to help you with your projects

PHP Music Player libraries let you create a music player application as easily as you would build a simple HTML page. As with any programming language, a significant amount of time is required to master PHP and make it useful in your projects. PHP Music Player libraries like AdvMusicPlayer, Noctifer-Music, php-music-player, core and many others are available to download in the official PHP downloads section of the PHP website. These libraries provide a way to play music from your files or streams, by using a simple object model. PHP-Music-Player is one of the most popular music player libraries, which can be easily built with the help of composer and Laravel. Noctifer-Music produces simple, high-quality music using current server technologies. AdvMusicPlayer performs advanced audio manipulation including pitch shifting, thresholding and time stretching. The AdvMusicPlayer can be used with any standard situation where a music player should be: on the web, in an application or as a console application. It supports the following music formats: mp3, ogg and wav. Using the library you can easily create unlimited playlists, search for song and artist names and generate playlists from their tags, as well as get track information from youtube/lastfm. It allows you to access detailed information about every single song in a playlist by displaying album covers in coverflow mode when playing songs in list view mode. It also enables you to increment/decrement play speed for individual songs or entire playlist. Popular open source PHP Music Player libraries include

One of the most popular types of music players are C++ libraries like Clementine, Musikcube, Strawberry, Olivia and MPZ. C++ Music Player libraries are used to play music in a variety of ways. They can be used to automatically download music from the internet, or to provide a basic user interface for managing music. These libraries have been designed by professional developers who know what they are doing when it comes to coding for audio players. Clementine is a cross-platform media player for GNOME 3 that supports a wide range of audio and video formats on the Linux desktop. The latest version of Clementine was released in February 2019 with improvements for scrobbling and an improved web interface for controlling playback. MusikCube music player is designed for Linux/Unix users who want to enjoy their music collection from different sources like local disk, network shares or portable devices. It's easy to use and supports many different audios file formats, as well as video files in various formats such as OGG and MP4 (h264). Strawberry is a cross-platform GTK+2 music player, which can play all common audio formats supported by gstreamer such as FLAC, MP3, Ogg Vorbis, Musepack (also known as MP1), AAC (M4A) and so on. Olivia is a lightweight GTK+ audio player that supports many popular formats. It features an easy-to-use interface with many configuration options and customizable behaviour via plugins. Popular open source C++ music player libraries among developers include

The use of Java Music Player libraries like MusicDNA, Phonograph, Shuttle, Auro and many others allows you to write a program that plays music with very simple code. These libraries can help you to create a custom music player application that works with your company's existing music library. The following sections describe some of the popular Java music player libraries and how they can be used in your applications. MusicDNA is a Java-based audio player that can play MP3, OGG, WAV and other audio formats. It supports ID3v2 tags and has a simple but powerful user interface. You can also download songs directly from the web or stream them over the Internet using the included HTTP server. Phonograph is a Java-based music player that supports ID3v2 and OGG tags. It has an easy to use interface with support for downloading songs directly from the Web. Shuttle is a Java-based music player that supports ID3v2 and OGG tags. It has an easy to use interface with support for downloading songs from the Web as well as streaming them over the Internet using the included HTTP server. Auro is a Java-based music player that supports ID3v2 and OGG tags. It has an easy to use interface with support for downloading songs from the Web as well as streaming them over the Internet using the included HTTP server. The entire list of open source Java Music Player libraries is provided below

Go Music Player is a free and open source media player for Android. The player is designed to be simple, fast and easy to use. It features a familiar interface from the classic MP3 players. The main advantage of using Go Music Player is that it has a very simple interface with no unnecessary features which makes it easier for users who are not tech savvy. PMS, Orchid, Ymuse and Gompd are the most popular ones. They have their respective plugins for browsers like Firefox, Chrome and Safari. I recommend using them if you want to use your favorite music player on the desktop or in a browser tab. Trollibox is another good choice if you want to use your favorite music player on your Android device (but it doesn't work well with headphones). Ymuse will help you learn how to play the guitar. It has many high-quality songs, which are all free and downloadable. You can also find videos on the site that show you exactly how to play each song. The Gompd library includes several different styles of music, including pop, rock and country. There is also a section of songs with lyrics included so that you can learn how to sing along with them if you choose. Many developers depend on the following open source Go Music Player libraries

Trending Discussions on Audio

Vuejs Webpack Compression Plugin not compressing

Different behavior between match and unwrap

IndexError: tuple index out of range when I try to create an executable from a python script using auto-py-to-exe

Javascript: frame precise video stop

How to detect if a device can play Dolby Atmos Sound with Javascript

FFMPEG's xstack command results in out of sync sound, is it possible to mix the audio in a single encoding?

How can I use value_counts() only for certain values?

Audio recording in Python with Pyaudio, error ||PaMacCore (AUHAL)|| ... msg=Audio Unit: cannot do in current context

Java mp4parser to create a single .m4s fragment— invalid moov box

Node.js - Client to Server WebRTC with P2P

QUESTION

Vuejs Webpack Compression Plugin not compressing

Asked 2022-Mar-28 at 12:53

I need help debugging Webpack's Compression Plugin.

SUMMARY OF PROBLEM

  • Goal is to enable asset compression and reduce my app's bundle size. Using the Brotli algorithm as the default, and gzip as a fallback for unsupported browsers.
  • I expected a content-encoding field within an asset's Response Headers. Instead, they're loaded without the field. I used the Chrome dev tools' network tab to confirm this. For context, see the following snippet: example asset request
  • No errors show in my browser or IDE when running locally.

WHAT I TRIED

  • Using different implementations for the compression plugin. See below list of approaches:
    1. (With Webpack Chain API)
1config
2 .plugin('brotliCompress')
3     .use(CompressionWebpackPlugin, [{
4       exclude: /.map$/,
5       cache: true,
6       algorithm: 'brotliCompress',
7       test: /\.(js|css|html|svg)$/,
8       threshold: 10240,
9       minRatio: 0.8,
10     }])
11
  1. (With Webpack Chain API)
1config
2 .plugin('brotliCompress')
3     .use(CompressionWebpackPlugin, [{
4       exclude: /.map$/,
5       cache: true,
6       algorithm: 'brotliCompress',
7       test: /\.(js|css|html|svg)$/,
8       threshold: 10240,
9       minRatio: 0.8,
10     }])
11config
12  .plugin('gzip')
13      .use(CompressionWebpackPlugin, [{
14        algorithm: 'gzip',
15        test: new RegExp('\\.(' + ['js', 'css'].join('|') + ')$'),
16        threshold: 8192, // Assets larger than 8192 bytes are not processed
17        minRatio: 0.8, // Assets compressing worse that this ratio are not processed
18      }])
19
  1. (With Webpack Chain API)
1config
2 .plugin('brotliCompress')
3     .use(CompressionWebpackPlugin, [{
4       exclude: /.map$/,
5       cache: true,
6       algorithm: 'brotliCompress',
7       test: /\.(js|css|html|svg)$/,
8       threshold: 10240,
9       minRatio: 0.8,
10     }])
11config
12  .plugin('gzip')
13      .use(CompressionWebpackPlugin, [{
14        algorithm: 'gzip',
15        test: new RegExp('\\.(' + ['js', 'css'].join('|') + ')$'),
16        threshold: 8192, // Assets larger than 8192 bytes are not processed
17        minRatio: 0.8, // Assets compressing worse that this ratio are not processed
18      }])
19config
20  .plugin('CompressionPlugin')
21      .use(CompressionWebpackPlugin)
22
  1. (Using vue-cli-plugin: compression) This fails due to a Missing generator error when I use vue invoke compression in response to an IDE console message after I run vue add compression as an alternative to using Webpack Chain API for compression configuration.
1config
2 .plugin('brotliCompress')
3     .use(CompressionWebpackPlugin, [{
4       exclude: /.map$/,
5       cache: true,
6       algorithm: 'brotliCompress',
7       test: /\.(js|css|html|svg)$/,
8       threshold: 10240,
9       minRatio: 0.8,
10     }])
11config
12  .plugin('gzip')
13      .use(CompressionWebpackPlugin, [{
14        algorithm: 'gzip',
15        test: new RegExp('\\.(' + ['js', 'css'].join('|') + ')$'),
16        threshold: 8192, // Assets larger than 8192 bytes are not processed
17        minRatio: 0.8, // Assets compressing worse that this ratio are not processed
18      }])
19config
20  .plugin('CompressionPlugin')
21      .use(CompressionWebpackPlugin)
22  pluginOptions: {
23    compression: {
24      brotli: {
25        filename: '[file].br[query]',
26        algorithm: 'brotliCompress',
27        include: /\.(js|css|html|svg|json)(\?.*)?$/i,
28        minRatio: 0.8,
29      },
30      gzip: {
31        filename: '[file].gz[query]',
32        algorithm: 'gzip',
33        include: /\.(js|css|html|svg|json)(\?.*)?$/i,
34        minRatio: 0.8
35      }
36    }
37  },
38
  1. Lastly, I tried setting the threshold field to 0 as well as raising it larger than 10k bytes.

POINTS OF SIGNIFICANCE

  • The above attempts didn't achieve the goal I stated in the first summary bullet and were used in place of the previous approaches tested.
  • I prioritized my efforts with Webpack Chain API since it resulted in no errors when rebuilding and running the app.

REFERENCED LINKS/DOCS

CODE

vue.config.js

1config
2 .plugin('brotliCompress')
3     .use(CompressionWebpackPlugin, [{
4       exclude: /.map$/,
5       cache: true,
6       algorithm: 'brotliCompress',
7       test: /\.(js|css|html|svg)$/,
8       threshold: 10240,
9       minRatio: 0.8,
10     }])
11config
12  .plugin('gzip')
13      .use(CompressionWebpackPlugin, [{
14        algorithm: 'gzip',
15        test: new RegExp('\\.(' + ['js', 'css'].join('|') + ')$'),
16        threshold: 8192, // Assets larger than 8192 bytes are not processed
17        minRatio: 0.8, // Assets compressing worse that this ratio are not processed
18      }])
19config
20  .plugin('CompressionPlugin')
21      .use(CompressionWebpackPlugin)
22  pluginOptions: {
23    compression: {
24      brotli: {
25        filename: '[file].br[query]',
26        algorithm: 'brotliCompress',
27        include: /\.(js|css|html|svg|json)(\?.*)?$/i,
28        minRatio: 0.8,
29      },
30      gzip: {
31        filename: '[file].gz[query]',
32        algorithm: 'gzip',
33        include: /\.(js|css|html|svg|json)(\?.*)?$/i,
34        minRatio: 0.8
35      }
36    }
37  },
38const path = require('path')
39const CompressionWebpackPlugin = require('compression-webpack-plugin')
40
41function resolve (dir) {
42  return path.join(__dirname, dir)
43}
44
45module.exports = {
46  /* ....shortened for brevity */
47
48  // Compress option VI (with vue cli plugin, generator bug when invoked)
49  // pluginOptions: {
50  //   compression: {
51  //     brotli: {
52  //       filename: '[file].br[query]',
53  //       algorithm: 'brotliCompress',
54  //       include: /\.(js|css|html|svg|json)(\?.*)?$/i,
55  //       minRatio: 0.8,
56  //     },
57  //     gzip: {
58  //       filename: '[file].gz[query]',
59  //       algorithm: 'gzip',
60  //       include: /\.(js|css|html|svg|json)(\?.*)?$/i,
61  //       minRatio: 0.8
62  //     }
63  //   }
64  // },
65
66  chainWebpack: config =&gt; {
67    config
68      .resolve.alias
69        .set('@', resolve('src'))
70
71    config
72      .plugins.delete('prefetch') 
73        
74    config
75      .optimization.splitChunks()
76
77    config
78      .output
79      .chunkFilename('[id].js')
80
81    // The below configurations are recommeneded only in prod.
82    // config.when(process.env.NODE_ENV === 'production', config =&gt; { config... })
83
84    // Compress option VII
85    // config
86      // .plugin('gzip')
87      // .use(CompressionWebpackPlugin, [{
88      //   algorithm: 'gzip',
89      //   test: new RegExp('\\.(' + ['js', 'css'].join('|') + ')$'),
90      //   threshold: 8192, // Assets larger than 8192 bytes are not processed
91      //   minRatio: 0.8, // Assets compressing worse that this ratio are not processed
92      // }])
93
94    // Compress option VIII
95    // config
96      // .plugin('CompressionPlugin')
97      // .use(CompressionWebpackPlugin)
98
99    config
100      .plugin('brotliCompress')
101      .use(CompressionWebpackPlugin, [{
102        exclude: /.map$/,
103        // deleteOriginalAssets: true,
104        cache: true,
105        algorithm: 'brotliCompress',
106        test: /\.(js|css|html|svg)$/,
107        threshold: 10240,
108        minRatio: 0.8,
109      }])
110  },
111}
112

package.json

1config
2 .plugin('brotliCompress')
3     .use(CompressionWebpackPlugin, [{
4       exclude: /.map$/,
5       cache: true,
6       algorithm: 'brotliCompress',
7       test: /\.(js|css|html|svg)$/,
8       threshold: 10240,
9       minRatio: 0.8,
10     }])
11config
12  .plugin('gzip')
13      .use(CompressionWebpackPlugin, [{
14        algorithm: 'gzip',
15        test: new RegExp('\\.(' + ['js', 'css'].join('|') + ')$'),
16        threshold: 8192, // Assets larger than 8192 bytes are not processed
17        minRatio: 0.8, // Assets compressing worse that this ratio are not processed
18      }])
19config
20  .plugin('CompressionPlugin')
21      .use(CompressionWebpackPlugin)
22  pluginOptions: {
23    compression: {
24      brotli: {
25        filename: '[file].br[query]',
26        algorithm: 'brotliCompress',
27        include: /\.(js|css|html|svg|json)(\?.*)?$/i,
28        minRatio: 0.8,
29      },
30      gzip: {
31        filename: '[file].gz[query]',
32        algorithm: 'gzip',
33        include: /\.(js|css|html|svg|json)(\?.*)?$/i,
34        minRatio: 0.8
35      }
36    }
37  },
38const path = require('path')
39const CompressionWebpackPlugin = require('compression-webpack-plugin')
40
41function resolve (dir) {
42  return path.join(__dirname, dir)
43}
44
45module.exports = {
46  /* ....shortened for brevity */
47
48  // Compress option VI (with vue cli plugin, generator bug when invoked)
49  // pluginOptions: {
50  //   compression: {
51  //     brotli: {
52  //       filename: '[file].br[query]',
53  //       algorithm: 'brotliCompress',
54  //       include: /\.(js|css|html|svg|json)(\?.*)?$/i,
55  //       minRatio: 0.8,
56  //     },
57  //     gzip: {
58  //       filename: '[file].gz[query]',
59  //       algorithm: 'gzip',
60  //       include: /\.(js|css|html|svg|json)(\?.*)?$/i,
61  //       minRatio: 0.8
62  //     }
63  //   }
64  // },
65
66  chainWebpack: config =&gt; {
67    config
68      .resolve.alias
69        .set('@', resolve('src'))
70
71    config
72      .plugins.delete('prefetch') 
73        
74    config
75      .optimization.splitChunks()
76
77    config
78      .output
79      .chunkFilename('[id].js')
80
81    // The below configurations are recommeneded only in prod.
82    // config.when(process.env.NODE_ENV === 'production', config =&gt; { config... })
83
84    // Compress option VII
85    // config
86      // .plugin('gzip')
87      // .use(CompressionWebpackPlugin, [{
88      //   algorithm: 'gzip',
89      //   test: new RegExp('\\.(' + ['js', 'css'].join('|') + ')$'),
90      //   threshold: 8192, // Assets larger than 8192 bytes are not processed
91      //   minRatio: 0.8, // Assets compressing worse that this ratio are not processed
92      // }])
93
94    // Compress option VIII
95    // config
96      // .plugin('CompressionPlugin')
97      // .use(CompressionWebpackPlugin)
98
99    config
100      .plugin('brotliCompress')
101      .use(CompressionWebpackPlugin, [{
102        exclude: /.map$/,
103        // deleteOriginalAssets: true,
104        cache: true,
105        algorithm: 'brotliCompress',
106        test: /\.(js|css|html|svg)$/,
107        threshold: 10240,
108        minRatio: 0.8,
109      }])
110  },
111}
112&quot;dependencies&quot;: {
113    &quot;@auth0/auth0-spa-js&quot;: &quot;^1.15.0&quot;,
114    &quot;audio-recorder-polyfill&quot;: &quot;^0.4.1&quot;,
115    &quot;compression-webpack-plugin&quot;: &quot;^6.0.0&quot;,
116    &quot;core-js&quot;: &quot;^3.6.5&quot;,
117    &quot;dotenv&quot;: &quot;^8.2.0&quot;,
118    &quot;dotenv-expand&quot;: &quot;^5.1.0&quot;,
119    &quot;moment&quot;: &quot;^2.29.1&quot;,
120    &quot;register-service-worker&quot;: &quot;^1.7.1&quot;,
121    &quot;uuid&quot;: &quot;^3.4.0&quot;,
122    &quot;vue&quot;: &quot;^2.6.11&quot;,
123    &quot;vue-loader&quot;: &quot;^15.9.8&quot;,
124    &quot;vue-router&quot;: &quot;^3.5.1&quot;,
125    &quot;vuex&quot;: &quot;^3.6.2&quot;
126  },
127  &quot;devDependencies&quot;: {
128    &quot;@vue/cli-plugin-babel&quot;: &quot;~4.5.0&quot;,
129    &quot;@vue/cli-plugin-eslint&quot;: &quot;~4.5.0&quot;,
130    &quot;@vue/cli-plugin-pwa&quot;: &quot;~4.5.0&quot;,
131    &quot;@vue/cli-service&quot;: &quot;~4.5.0&quot;,
132    &quot;babel-eslint&quot;: &quot;^10.1.0&quot;,
133    &quot;eslint&quot;: &quot;^6.7.2&quot;,
134    &quot;eslint-plugin-vue&quot;: &quot;^6.2.2&quot;,
135    &quot;vue-cli-plugin-compression&quot;: &quot;~1.1.5&quot;,
136    &quot;vue-template-compiler&quot;: &quot;^2.6.11&quot;,
137    &quot;webpack&quot;: &quot;^4.46.0&quot;
138  }
139

I appreciate all input. Thanks.

ANSWER

Answered 2021-Sep-30 at 14:59

It's not clear which server is serving up these assets. If it's Express, looking at the screenshot with the header X-Powered-By, https://github.com/expressjs/compression/issues/71 shows that Brotli support hasn't been added to Express yet.

There might be a way to just specify the header for content-encoding manually though.

Source https://stackoverflow.com/questions/69288974

QUESTION

Different behavior between match and unwrap

Asked 2022-Mar-15 at 18:39

I have done a small program, and it shows a weird behavior that I cannot explain. I am using rodio crate to try out some audio stuff.

I have done two programs that, in my opinion, should give the same result.

The first one I use matches to handle errors:

1let sink : Option&lt;Sink&gt; = match rodio::OutputStream::try_default() {
2        Ok((_, handle)) =&gt; {
3            match Sink::try_new(&amp;handle) {
4                Ok(s) =&gt; Some(s),
5                Err(_e) =&gt; None,
6            }
7        },
8        Err(_e) =&gt; None,
9};
10println!(&quot;{}&quot;, sink.unwrap().len());
11

In the last one, I have used unwrap instead.

1let sink : Option&lt;Sink&gt; = match rodio::OutputStream::try_default() {
2        Ok((_, handle)) =&gt; {
3            match Sink::try_new(&amp;handle) {
4                Ok(s) =&gt; Some(s),
5                Err(_e) =&gt; None,
6            }
7        },
8        Err(_e) =&gt; None,
9};
10println!(&quot;{}&quot;, sink.unwrap().len());
11let (_, handle) = rodio::OutputStream::try_default().unwrap();
12let s = Sink::try_new(&amp;handle).unwrap();
13println!(&quot;{}&quot;,s.len());
14

The first one executes the print statement as expected, while the last one panics in the second unwrap.

It is very strange to me as soon as there is no error propagation, implicit conversions or other things that can explain that. The problem here is not related to the error itself but the difference between the two codes.

ANSWER

Answered 2021-Sep-30 at 19:08

The issue is one of scoping and an implementation detail of rodio: the one critical item here is OutputStream::try_default(), it doesn't really matter how you handle Sink::try_new(&handle) it'll always behave the same, not so try_default, if you match or if let it it'll work fine, if you unwrap it it'll fail.

But why would that be, the two should be equivalent. The answer is in the details of rodio, specifically of OutputStreamHandle:

1let sink : Option&lt;Sink&gt; = match rodio::OutputStream::try_default() {
2        Ok((_, handle)) =&gt; {
3            match Sink::try_new(&amp;handle) {
4                Ok(s) =&gt; Some(s),
5                Err(_e) =&gt; None,
6            }
7        },
8        Err(_e) =&gt; None,
9};
10println!(&quot;{}&quot;, sink.unwrap().len());
11let (_, handle) = rodio::OutputStream::try_default().unwrap();
12let s = Sink::try_new(&amp;handle).unwrap();
13println!(&quot;{}&quot;,s.len());
14pub struct OutputStreamHandle {
15    mixer: Weak&lt;DynamicMixerController&lt;f32&gt;&gt;,
16}
17

So an OutputStreamHandle (OSH thereafter) only holds a weakref to a DynamicMixerController, to which the OutputStream (OS thereafter) holds a strong reference.

This means the OSH only "works" as long as the OS is alive.

1let sink : Option&lt;Sink&gt; = match rodio::OutputStream::try_default() {
2        Ok((_, handle)) =&gt; {
3            match Sink::try_new(&amp;handle) {
4                Ok(s) =&gt; Some(s),
5                Err(_e) =&gt; None,
6            }
7        },
8        Err(_e) =&gt; None,
9};
10println!(&quot;{}&quot;, sink.unwrap().len());
11let (_, handle) = rodio::OutputStream::try_default().unwrap();
12let s = Sink::try_new(&amp;handle).unwrap();
13println!(&quot;{}&quot;,s.len());
14pub struct OutputStreamHandle {
15    mixer: Weak&lt;DynamicMixerController&lt;f32&gt;&gt;,
16}
17let (_, handle) = OutputStream::try_default().unwrap();
18

does not name the OS, so doesn't hold onto it, it's immediately dropped, the Arc is released and the OSH holds onto nothing, and the sink is unhappy.

How can the other one work then? Because

1let sink : Option&lt;Sink&gt; = match rodio::OutputStream::try_default() {
2        Ok((_, handle)) =&gt; {
3            match Sink::try_new(&amp;handle) {
4                Ok(s) =&gt; Some(s),
5                Err(_e) =&gt; None,
6            }
7        },
8        Err(_e) =&gt; None,
9};
10println!(&quot;{}&quot;, sink.unwrap().len());
11let (_, handle) = rodio::OutputStream::try_default().unwrap();
12let s = Sink::try_new(&amp;handle).unwrap();
13println!(&quot;{}&quot;,s.len());
14pub struct OutputStreamHandle {
15    mixer: Weak&lt;DynamicMixerController&lt;f32&gt;&gt;,
16}
17let (_, handle) = OutputStream::try_default().unwrap();
18    if let Ok((_, handle)) = OutputStream::try_default() {
19        let sink = Sink::try_new(&amp;handle).unwrap();
20        println!(&quot;match {}&quot;, sink.len());
21    }
22

is really rather

1let sink : Option&lt;Sink&gt; = match rodio::OutputStream::try_default() {
2        Ok((_, handle)) =&gt; {
3            match Sink::try_new(&amp;handle) {
4                Ok(s) =&gt; Some(s),
5                Err(_e) =&gt; None,
6            }
7        },
8        Err(_e) =&gt; None,
9};
10println!(&quot;{}&quot;, sink.unwrap().len());
11let (_, handle) = rodio::OutputStream::try_default().unwrap();
12let s = Sink::try_new(&amp;handle).unwrap();
13println!(&quot;{}&quot;,s.len());
14pub struct OutputStreamHandle {
15    mixer: Weak&lt;DynamicMixerController&lt;f32&gt;&gt;,
16}
17let (_, handle) = OutputStream::try_default().unwrap();
18    if let Ok((_, handle)) = OutputStream::try_default() {
19        let sink = Sink::try_new(&amp;handle).unwrap();
20        println!(&quot;match {}&quot;, sink.len());
21    }
22{
23    let _var = OutputStream::try_default();
24    if let Ok((_, handle)) = _var {
25        let sink = Sink::try_new(&amp;handle).unwrap();
26        println!(&quot;match {}&quot;, sink.len());
27    }
28}
29

so the match/if let itself is keeping the Result alive, which is a blessing here (but causes issues just the next question over).

Since the Result is kept alive, the tuple is kept alive, the OutputStream is kept alive, the Arc is kept alive, and thus the OSH has a working mixer, which the sink can make use of.

You can fix the issue of the second version by binding the OutputStream to a "proper" name e.g.

1let sink : Option&lt;Sink&gt; = match rodio::OutputStream::try_default() {
2        Ok((_, handle)) =&gt; {
3            match Sink::try_new(&amp;handle) {
4                Ok(s) =&gt; Some(s),
5                Err(_e) =&gt; None,
6            }
7        },
8        Err(_e) =&gt; None,
9};
10println!(&quot;{}&quot;, sink.unwrap().len());
11let (_, handle) = rodio::OutputStream::try_default().unwrap();
12let s = Sink::try_new(&amp;handle).unwrap();
13println!(&quot;{}&quot;,s.len());
14pub struct OutputStreamHandle {
15    mixer: Weak&lt;DynamicMixerController&lt;f32&gt;&gt;,
16}
17let (_, handle) = OutputStream::try_default().unwrap();
18    if let Ok((_, handle)) = OutputStream::try_default() {
19        let sink = Sink::try_new(&amp;handle).unwrap();
20        println!(&quot;match {}&quot;, sink.len());
21    }
22{
23    let _var = OutputStream::try_default();
24    if let Ok((_, handle)) = _var {
25        let sink = Sink::try_new(&amp;handle).unwrap();
26        println!(&quot;match {}&quot;, sink.len());
27    }
28}
29let (_stream, handle) = OutputStream::try_default().unwrap();
30

prefixing a name with _ will create the binding for real, but will suppress the "unused variable" warning.

FWIW being careful around this sort of things is incredibly important around RAII types whose values you "don't need", most commonly mutexes protecting code as opposed to data:

1let sink : Option&lt;Sink&gt; = match rodio::OutputStream::try_default() {
2        Ok((_, handle)) =&gt; {
3            match Sink::try_new(&amp;handle) {
4                Ok(s) =&gt; Some(s),
5                Err(_e) =&gt; None,
6            }
7        },
8        Err(_e) =&gt; None,
9};
10println!(&quot;{}&quot;, sink.unwrap().len());
11let (_, handle) = rodio::OutputStream::try_default().unwrap();
12let s = Sink::try_new(&amp;handle).unwrap();
13println!(&quot;{}&quot;,s.len());
14pub struct OutputStreamHandle {
15    mixer: Weak&lt;DynamicMixerController&lt;f32&gt;&gt;,
16}
17let (_, handle) = OutputStream::try_default().unwrap();
18    if let Ok((_, handle)) = OutputStream::try_default() {
19        let sink = Sink::try_new(&amp;handle).unwrap();
20        println!(&quot;match {}&quot;, sink.len());
21    }
22{
23    let _var = OutputStream::try_default();
24    if let Ok((_, handle)) = _var {
25        let sink = Sink::try_new(&amp;handle).unwrap();
26        println!(&quot;match {}&quot;, sink.len());
27    }
28}
29let (_stream, handle) = OutputStream::try_default().unwrap();
30let _ = m.lock().unwrap();
31

doesn't do anything, the mutex guard is not kept alive, so the lock is immediately released. In that case, you'd rather

1let sink : Option&lt;Sink&gt; = match rodio::OutputStream::try_default() {
2        Ok((_, handle)) =&gt; {
3            match Sink::try_new(&amp;handle) {
4                Ok(s) =&gt; Some(s),
5                Err(_e) =&gt; None,
6            }
7        },
8        Err(_e) =&gt; None,
9};
10println!(&quot;{}&quot;, sink.unwrap().len());
11let (_, handle) = rodio::OutputStream::try_default().unwrap();
12let s = Sink::try_new(&amp;handle).unwrap();
13println!(&quot;{}&quot;,s.len());
14pub struct OutputStreamHandle {
15    mixer: Weak&lt;DynamicMixerController&lt;f32&gt;&gt;,
16}
17let (_, handle) = OutputStream::try_default().unwrap();
18    if let Ok((_, handle)) = OutputStream::try_default() {
19        let sink = Sink::try_new(&amp;handle).unwrap();
20        println!(&quot;match {}&quot;, sink.len());
21    }
22{
23    let _var = OutputStream::try_default();
24    if let Ok((_, handle)) = _var {
25        let sink = Sink::try_new(&amp;handle).unwrap();
26        println!(&quot;match {}&quot;, sink.len());
27    }
28}
29let (_stream, handle) = OutputStream::try_default().unwrap();
30let _ = m.lock().unwrap();
31let _lock = m.lock().unwrap():
32

or even better

1let sink : Option&lt;Sink&gt; = match rodio::OutputStream::try_default() {
2        Ok((_, handle)) =&gt; {
3            match Sink::try_new(&amp;handle) {
4                Ok(s) =&gt; Some(s),
5                Err(_e) =&gt; None,
6            }
7        },
8        Err(_e) =&gt; None,
9};
10println!(&quot;{}&quot;, sink.unwrap().len());
11let (_, handle) = rodio::OutputStream::try_default().unwrap();
12let s = Sink::try_new(&amp;handle).unwrap();
13println!(&quot;{}&quot;,s.len());
14pub struct OutputStreamHandle {
15    mixer: Weak&lt;DynamicMixerController&lt;f32&gt;&gt;,
16}
17let (_, handle) = OutputStream::try_default().unwrap();
18    if let Ok((_, handle)) = OutputStream::try_default() {
19        let sink = Sink::try_new(&amp;handle).unwrap();
20        println!(&quot;match {}&quot;, sink.len());
21    }
22{
23    let _var = OutputStream::try_default();
24    if let Ok((_, handle)) = _var {
25        let sink = Sink::try_new(&amp;handle).unwrap();
26        println!(&quot;match {}&quot;, sink.len());
27    }
28}
29let (_stream, handle) = OutputStream::try_default().unwrap();
30let _ = m.lock().unwrap();
31let _lock = m.lock().unwrap():
32let lock = m.lock().unwrap();
33...
34drop(lock);
35

Source https://stackoverflow.com/questions/69393226

QUESTION

IndexError: tuple index out of range when I try to create an executable from a python script using auto-py-to-exe

Asked 2022-Feb-24 at 15:03

I have been trying out an open-sourced personal AI assistant script. The script works fine but I want to create an executable so that I can gift the executable to one of my friends. However, when I try to create the executable using the auto-py-to-exe, it states the below error:

1Running auto-py-to-exe v2.10.1
2Building directory: C:\Users\Tarun\AppData\Local\Temp\tmpjaw1ky1x
3Provided command: pyinstaller --noconfirm --onedir --console --no-embed-manifest  &quot;C:/Users/Tarun/AppData/Local/Programs/Python/Python310/AI_Ass.py&quot;
4Recursion Limit is set to 5000
5Executing: pyinstaller --noconfirm --onedir --console --no-embed-manifest C:/Users/Tarun/AppData/Local/Programs/Python/Python310/AI_Ass.py --distpath C:\Users\Tarun\AppData\Local\Temp\tmpjaw1ky1x\application --workpath C:\Users\Tarun\AppData\Local\Temp\tmpjaw1ky1x\build --specpath C:\Users\Tarun\AppData\Local\Temp\tmpjaw1ky1x
6
742681 INFO: PyInstaller: 4.6
842690 INFO: Python: 3.10.0
942732 INFO: Platform: Windows-10-10.0.19042-SP0
1042744 INFO: wrote C:\Users\Tarun\AppData\Local\Temp\tmpjaw1ky1x\AI_Ass.spec
1142764 INFO: UPX is not available.
1242772 INFO: Extending PYTHONPATH with paths
13['C:\\Users\\Tarun\\AppData\\Local\\Programs\\Python\\Python310']
1443887 INFO: checking Analysis
1543891 INFO: Building Analysis because Analysis-00.toc is non existent
1643895 INFO: Initializing module dependency graph...
1743915 INFO: Caching module graph hooks...
1843975 INFO: Analyzing base_library.zip ...
1954298 INFO: Processing pre-find module path hook distutils from 'C:\\Users\\Tarun\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
2054306 INFO: distutils: retargeting to non-venv dir 'C:\\Users\\Tarun\\AppData\\Local\\Programs\\Python\\Python310\\lib'
2157474 INFO: Caching module dependency graph...
2258088 INFO: running Analysis Analysis-00.toc
2358132 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
24  required by C:\Users\Tarun\AppData\Local\Programs\Python\Python310\python.exe
2558365 INFO: Analyzing C:\Users\Tarun\AppData\Local\Programs\Python\Python310\AI_Ass.py
2659641 INFO: Processing pre-safe import module hook urllib3.packages.six.moves from 'C:\\Users\\Tarun\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-urllib3.packages.six.moves.py'.
27An error occurred while packaging
28Traceback (most recent call last):
29  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\auto_py_to_exe\packaging.py&quot;, line 131, in package
30    run_pyinstaller()
31  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\__main__.py&quot;, line 124, in run
32    run_build(pyi_config, spec_file, **vars(args))
33  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\__main__.py&quot;, line 58, in run_build
34    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
35  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\building\build_main.py&quot;, line 782, in main
36    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
37  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\building\build_main.py&quot;, line 714, in build
38    exec(code, spec_namespace)
39  File &quot;C:\Users\Tarun\AppData\Local\Temp\tmpjaw1ky1x\AI_Ass.spec&quot;, line 7, in &lt;module&gt;
40    a = Analysis(['C:/Users/Tarun/AppData/Local/Programs/Python/Python310/AI_Ass.py'],
41  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\building\build_main.py&quot;, line 277, in __init__
42    self.__postinit__()
43  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\building\datastruct.py&quot;, line 155, in __postinit__
44    self.assemble()
45  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\building\build_main.py&quot;, line 439, in assemble
46    priority_scripts.append(self.graph.add_script(script))
47  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py&quot;, line 265, in add_script
48    self._top_script_node = super().add_script(pathname)
49  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1433, in add_script
50    self._process_imports(n)
51  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2850, in _process_imports
52    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
53  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2301, in _safe_import_hook
54    target_modules = self.import_hook(
55  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1505, in import_hook
56    target_package, target_module_partname = self._find_head_package(
57  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1684, in _find_head_package
58    target_package = self._safe_import_module(
59  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py&quot;, line 387, in _safe_import_module
60    return super()._safe_import_module(module_basename, module_name, parent_package)
61  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2062, in _safe_import_module
62    self._process_imports(n)
63  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2850, in _process_imports
64    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
65  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2301, in _safe_import_hook
66    target_modules = self.import_hook(
67  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1505, in import_hook
68    target_package, target_module_partname = self._find_head_package(
69  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1684, in _find_head_package
70    target_package = self._safe_import_module(
71  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py&quot;, line 387, in _safe_import_module
72    return super()._safe_import_module(module_basename, module_name, parent_package)
73  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2062, in _safe_import_module
74    self._process_imports(n)
75  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2850, in _process_imports
76    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
77  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2301, in _safe_import_hook
78    target_modules = self.import_hook(
79  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1505, in import_hook
80    target_package, target_module_partname = self._find_head_package(
81  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1684, in _find_head_package
82    target_package = self._safe_import_module(
83  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py&quot;, line 387, in _safe_import_module
84    return super()._safe_import_module(module_basename, module_name, parent_package)
85  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2062, in _safe_import_module
86    self._process_imports(n)
87  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2850, in _process_imports
88    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
89  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2301, in _safe_import_hook
90    target_modules = self.import_hook(
91  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1505, in import_hook
92    target_package, target_module_partname = self._find_head_package(
93  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1684, in _find_head_package
94    target_package = self._safe_import_module(
95  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py&quot;, line 387, in _safe_import_module
96    return super()._safe_import_module(module_basename, module_name, parent_package)
97  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2062, in _safe_import_module
98    self._process_imports(n)
99  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2850, in _process_imports
100    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
101  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2301, in _safe_import_hook
102    target_modules = self.import_hook(
103  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1518, in import_hook
104    submodule = self._safe_import_module(head, mname, submodule)
105  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py&quot;, line 387, in _safe_import_module
106    return super()._safe_import_module(module_basename, module_name, parent_package)
107  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2062, in _safe_import_module
108    self._process_imports(n)
109  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2850, in _process_imports
110    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
111  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2301, in _safe_import_hook
112    target_modules = self.import_hook(
113  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1518, in import_hook
114    submodule = self._safe_import_module(head, mname, submodule)
115  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py&quot;, line 387, in _safe_import_module
116    return super()._safe_import_module(module_basename, module_name, parent_package)
117  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2062, in _safe_import_module
118    self._process_imports(n)
119  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2850, in _process_imports
120    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
121  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2301, in _safe_import_hook
122    target_modules = self.import_hook(
123  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1518, in import_hook
124    submodule = self._safe_import_module(head, mname, submodule)
125  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py&quot;, line 387, in _safe_import_module
126    return super()._safe_import_module(module_basename, module_name, parent_package)
127  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2061, in _safe_import_module
128    n = self._scan_code(module, co, co_ast)
129  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2645, in _scan_code
130    self._scan_bytecode(
131  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2749, in _scan_bytecode
132    for inst in util.iterate_instructions(module_code_object):
133  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\util.py&quot;, line 147, in iterate_instructions
134    yield from iterate_instructions(constant)
135  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\util.py&quot;, line 139, in iterate_instructions
136    yield from get_instructions(code_object)
137  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\dis.py&quot;, line 338, in _get_instructions_bytes
138    argval, argrepr = _get_const_info(arg, constants)
139  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\dis.py&quot;, line 292, in _get_const_info
140    argval = const_list[const_index]
141IndexError: tuple index out of range
142
143Project output will not be moved to output folder
144Complete.
145

I understand that there is a thread already about similar issue but it still doesn't solve the issue. Hence seeking out help

I really have no idea why is the error occurring and how to resolve it. I am pasting the script below for your reference. Can some one please help? Thank you in advance

1Running auto-py-to-exe v2.10.1
2Building directory: C:\Users\Tarun\AppData\Local\Temp\tmpjaw1ky1x
3Provided command: pyinstaller --noconfirm --onedir --console --no-embed-manifest  &quot;C:/Users/Tarun/AppData/Local/Programs/Python/Python310/AI_Ass.py&quot;
4Recursion Limit is set to 5000
5Executing: pyinstaller --noconfirm --onedir --console --no-embed-manifest C:/Users/Tarun/AppData/Local/Programs/Python/Python310/AI_Ass.py --distpath C:\Users\Tarun\AppData\Local\Temp\tmpjaw1ky1x\application --workpath C:\Users\Tarun\AppData\Local\Temp\tmpjaw1ky1x\build --specpath C:\Users\Tarun\AppData\Local\Temp\tmpjaw1ky1x
6
742681 INFO: PyInstaller: 4.6
842690 INFO: Python: 3.10.0
942732 INFO: Platform: Windows-10-10.0.19042-SP0
1042744 INFO: wrote C:\Users\Tarun\AppData\Local\Temp\tmpjaw1ky1x\AI_Ass.spec
1142764 INFO: UPX is not available.
1242772 INFO: Extending PYTHONPATH with paths
13['C:\\Users\\Tarun\\AppData\\Local\\Programs\\Python\\Python310']
1443887 INFO: checking Analysis
1543891 INFO: Building Analysis because Analysis-00.toc is non existent
1643895 INFO: Initializing module dependency graph...
1743915 INFO: Caching module graph hooks...
1843975 INFO: Analyzing base_library.zip ...
1954298 INFO: Processing pre-find module path hook distutils from 'C:\\Users\\Tarun\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
2054306 INFO: distutils: retargeting to non-venv dir 'C:\\Users\\Tarun\\AppData\\Local\\Programs\\Python\\Python310\\lib'
2157474 INFO: Caching module dependency graph...
2258088 INFO: running Analysis Analysis-00.toc
2358132 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
24  required by C:\Users\Tarun\AppData\Local\Programs\Python\Python310\python.exe
2558365 INFO: Analyzing C:\Users\Tarun\AppData\Local\Programs\Python\Python310\AI_Ass.py
2659641 INFO: Processing pre-safe import module hook urllib3.packages.six.moves from 'C:\\Users\\Tarun\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-urllib3.packages.six.moves.py'.
27An error occurred while packaging
28Traceback (most recent call last):
29  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\auto_py_to_exe\packaging.py&quot;, line 131, in package
30    run_pyinstaller()
31  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\__main__.py&quot;, line 124, in run
32    run_build(pyi_config, spec_file, **vars(args))
33  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\__main__.py&quot;, line 58, in run_build
34    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
35  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\building\build_main.py&quot;, line 782, in main
36    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
37  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\building\build_main.py&quot;, line 714, in build
38    exec(code, spec_namespace)
39  File &quot;C:\Users\Tarun\AppData\Local\Temp\tmpjaw1ky1x\AI_Ass.spec&quot;, line 7, in &lt;module&gt;
40    a = Analysis(['C:/Users/Tarun/AppData/Local/Programs/Python/Python310/AI_Ass.py'],
41  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\building\build_main.py&quot;, line 277, in __init__
42    self.__postinit__()
43  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\building\datastruct.py&quot;, line 155, in __postinit__
44    self.assemble()
45  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\building\build_main.py&quot;, line 439, in assemble
46    priority_scripts.append(self.graph.add_script(script))
47  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py&quot;, line 265, in add_script
48    self._top_script_node = super().add_script(pathname)
49  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1433, in add_script
50    self._process_imports(n)
51  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2850, in _process_imports
52    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
53  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2301, in _safe_import_hook
54    target_modules = self.import_hook(
55  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1505, in import_hook
56    target_package, target_module_partname = self._find_head_package(
57  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1684, in _find_head_package
58    target_package = self._safe_import_module(
59  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py&quot;, line 387, in _safe_import_module
60    return super()._safe_import_module(module_basename, module_name, parent_package)
61  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2062, in _safe_import_module
62    self._process_imports(n)
63  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2850, in _process_imports
64    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
65  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2301, in _safe_import_hook
66    target_modules = self.import_hook(
67  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1505, in import_hook
68    target_package, target_module_partname = self._find_head_package(
69  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1684, in _find_head_package
70    target_package = self._safe_import_module(
71  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py&quot;, line 387, in _safe_import_module
72    return super()._safe_import_module(module_basename, module_name, parent_package)
73  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2062, in _safe_import_module
74    self._process_imports(n)
75  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2850, in _process_imports
76    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
77  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2301, in _safe_import_hook
78    target_modules = self.import_hook(
79  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1505, in import_hook
80    target_package, target_module_partname = self._find_head_package(
81  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1684, in _find_head_package
82    target_package = self._safe_import_module(
83  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py&quot;, line 387, in _safe_import_module
84    return super()._safe_import_module(module_basename, module_name, parent_package)
85  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2062, in _safe_import_module
86    self._process_imports(n)
87  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2850, in _process_imports
88    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
89  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2301, in _safe_import_hook
90    target_modules = self.import_hook(
91  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1505, in import_hook
92    target_package, target_module_partname = self._find_head_package(
93  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1684, in _find_head_package
94    target_package = self._safe_import_module(
95  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py&quot;, line 387, in _safe_import_module
96    return super()._safe_import_module(module_basename, module_name, parent_package)
97  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2062, in _safe_import_module
98    self._process_imports(n)
99  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2850, in _process_imports
100    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
101  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2301, in _safe_import_hook
102    target_modules = self.import_hook(
103  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1518, in import_hook
104    submodule = self._safe_import_module(head, mname, submodule)
105  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py&quot;, line 387, in _safe_import_module
106    return super()._safe_import_module(module_basename, module_name, parent_package)
107  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2062, in _safe_import_module
108    self._process_imports(n)
109  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2850, in _process_imports
110    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
111  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2301, in _safe_import_hook
112    target_modules = self.import_hook(
113  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1518, in import_hook
114    submodule = self._safe_import_module(head, mname, submodule)
115  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py&quot;, line 387, in _safe_import_module
116    return super()._safe_import_module(module_basename, module_name, parent_package)
117  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2062, in _safe_import_module
118    self._process_imports(n)
119  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2850, in _process_imports
120    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
121  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2301, in _safe_import_hook
122    target_modules = self.import_hook(
123  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1518, in import_hook
124    submodule = self._safe_import_module(head, mname, submodule)
125  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py&quot;, line 387, in _safe_import_module
126    return super()._safe_import_module(module_basename, module_name, parent_package)
127  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2061, in _safe_import_module
128    n = self._scan_code(module, co, co_ast)
129  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2645, in _scan_code
130    self._scan_bytecode(
131  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2749, in _scan_bytecode
132    for inst in util.iterate_instructions(module_code_object):
133  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\util.py&quot;, line 147, in iterate_instructions
134    yield from iterate_instructions(constant)
135  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\util.py&quot;, line 139, in iterate_instructions
136    yield from get_instructions(code_object)
137  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\dis.py&quot;, line 338, in _get_instructions_bytes
138    argval, argrepr = _get_const_info(arg, constants)
139  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\dis.py&quot;, line 292, in _get_const_info
140    argval = const_list[const_index]
141IndexError: tuple index out of range
142
143Project output will not be moved to output folder
144Complete.
145#importing libraries
146
147import speech_recognition as sr
148import pyttsx3
149import datetime
150import wikipedia
151import webbrowser
152import os
153import time
154import subprocess
155from   ecapture import ecapture as ec
156import wolframalpha
157import json
158import requests
159
160#setting up speech engine
161engine=pyttsx3.init('sapi5')
162voices=engine.getProperty('voices')
163engine.setProperty('voice','voices[1].id')
164
165def speak(text):
166    engine.say(text)
167    engine.runAndWait()
168    
169#Greet user
170def wishMe():
171    hour=datetime.datetime.now().hour
172    if hour&gt;=0 and hour&lt;12:
173        speak(&quot;Hello,Good Morning&quot;)
174        print(&quot;Hello,Good Morning&quot;)
175    elif hour&gt;=12 and hour&lt;18:
176        speak(&quot;Hello,Good Afternoon&quot;)
177        print(&quot;Hello,Good Afternoon&quot;)
178    else:
179        speak(&quot;Hello,Good Evening&quot;)
180        print(&quot;Hello,Good Evening&quot;)
181
182#Setting up the command function for your AI assistant
183def takeCommand():
184    r=sr.Recognizer()
185    with sr.Microphone() as source:
186        print(&quot;Listening...&quot;)
187        audio=r.listen(source)
188
189        try:
190            statement=r.recognize_google(audio,language='en-in')
191            print(f&quot;user said:{statement}\n&quot;)
192
193        except Exception as e:
194            speak(&quot;Pardon me, please say that again&quot;)
195            return &quot;None&quot;
196        return statement
197
198print(&quot;Loading your AI personal assistant Friday&quot;)
199speak(&quot;Loading your AI personal assistant Friday&quot;)
200wishMe()
201
202#main function
203if __name__=='__main__':
204
205
206    while True:
207        speak(&quot;Tell me how can I help you now?&quot;)
208        statement = takeCommand().lower()
209        if statement==0:
210            continue
211
212        if &quot;good bye&quot; in statement or &quot;ok bye&quot; in statement or &quot;stop&quot; in statement:
213            speak('your personal assistant Friday is shutting down,Good bye')
214            print('your personal assistant Friday is shutting down,Good bye')
215            break
216
217
218        if 'wikipedia' in statement:
219            speak('Searching Wikipedia...')
220            statement =statement.replace(&quot;wikipedia&quot;, &quot;&quot;)
221            results = wikipedia.summary(statement, sentences=10)
222            webbrowser.open_new_tab(&quot;https://en.wikipedia.org/wiki/&quot;+ statement)
223            speak(&quot;According to Wikipedia&quot;)
224            print(results)
225            speak(results)
226
227        elif 'open youtube' in statement:
228            webbrowser.register('chrome', None,
229        webbrowser.BackgroundBrowser(&quot;C://Program Files (x86)//Google//Chrome//Application//chrome.exe&quot;))
230            webbrowser.get('chrome').open_new_tab(&quot;https://www.youtube.com&quot;)
231            #webbrowser.open_new_tab(&quot;https://www.youtube.com&quot;)
232            speak(&quot;youtube is open now&quot;)
233            time.sleep(5)
234
235        elif 'open google' in statement:
236            webbrowser.open_new_tab(&quot;https://www.google.com&quot;)
237            speak(&quot;Google chrome is open now&quot;)
238            time.sleep(5)
239
240        elif 'open gmail' in statement:
241            webbrowser.open_new_tab(&quot;gmail.com&quot;)
242            speak(&quot;Google Mail open now&quot;)
243            time.sleep(5)
244        
245        elif 'time' in statement:
246            strTime=datetime.datetime.now().strftime(&quot;%H:%M:%S&quot;)
247            speak(f&quot;the time is {strTime}&quot;)
248
249        elif 'news' in statement:
250            news = webbrowser.open_new_tab(&quot;https://timesofindia.indiatimes.com/home/headlines&quot;)
251            speak('Here are some headlines from the Times of India,Happy reading')
252            time.sleep(6)
253
254        elif &quot;camera&quot; in statement or &quot;take a photo&quot; in statement:
255            ec.capture(0,&quot;robo camera&quot;,&quot;img.jpg&quot;)
256
257        elif 'search' in statement:
258            statement = statement.replace(&quot;search&quot;, &quot;&quot;)
259            webbrowser.open_new_tab(statement)
260            time.sleep(5)
261
262        elif 'who are you' in statement or 'what can you do' in statement:
263            speak('I am Friday version 1 point O your personal assistant. I am programmed to minor tasks like'
264            'opening youtube,google chrome, gmail and stackoverflow ,predict time,take a photo,search wikipedia,predict weather' 
265            'In different cities, get top headline news from times of india and you can ask me computational or geographical questions too!')
266
267
268        elif &quot;who made you&quot; in statement or &quot;who created you&quot; in statement or &quot;who discovered you&quot; in statement:
269            speak(&quot;I was built by Mirthula&quot;)
270            print(&quot;I was built by Mirthula&quot;)
271
272        elif &quot;log off&quot; in statement or &quot;sign out&quot; in statement:
273            speak(&quot;Ok , your pc will log off in 10 sec make sure you exit from all applications&quot;)
274            subprocess.call([&quot;shutdown&quot;, &quot;/l&quot;])
275            
276time.sleep(3)
277

ANSWER

Answered 2021-Nov-05 at 02:20
1Running auto-py-to-exe v2.10.1
2Building directory: C:\Users\Tarun\AppData\Local\Temp\tmpjaw1ky1x
3Provided command: pyinstaller --noconfirm --onedir --console --no-embed-manifest  &quot;C:/Users/Tarun/AppData/Local/Programs/Python/Python310/AI_Ass.py&quot;
4Recursion Limit is set to 5000
5Executing: pyinstaller --noconfirm --onedir --console --no-embed-manifest C:/Users/Tarun/AppData/Local/Programs/Python/Python310/AI_Ass.py --distpath C:\Users\Tarun\AppData\Local\Temp\tmpjaw1ky1x\application --workpath C:\Users\Tarun\AppData\Local\Temp\tmpjaw1ky1x\build --specpath C:\Users\Tarun\AppData\Local\Temp\tmpjaw1ky1x
6
742681 INFO: PyInstaller: 4.6
842690 INFO: Python: 3.10.0
942732 INFO: Platform: Windows-10-10.0.19042-SP0
1042744 INFO: wrote C:\Users\Tarun\AppData\Local\Temp\tmpjaw1ky1x\AI_Ass.spec
1142764 INFO: UPX is not available.
1242772 INFO: Extending PYTHONPATH with paths
13['C:\\Users\\Tarun\\AppData\\Local\\Programs\\Python\\Python310']
1443887 INFO: checking Analysis
1543891 INFO: Building Analysis because Analysis-00.toc is non existent
1643895 INFO: Initializing module dependency graph...
1743915 INFO: Caching module graph hooks...
1843975 INFO: Analyzing base_library.zip ...
1954298 INFO: Processing pre-find module path hook distutils from 'C:\\Users\\Tarun\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
2054306 INFO: distutils: retargeting to non-venv dir 'C:\\Users\\Tarun\\AppData\\Local\\Programs\\Python\\Python310\\lib'
2157474 INFO: Caching module dependency graph...
2258088 INFO: running Analysis Analysis-00.toc
2358132 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
24  required by C:\Users\Tarun\AppData\Local\Programs\Python\Python310\python.exe
2558365 INFO: Analyzing C:\Users\Tarun\AppData\Local\Programs\Python\Python310\AI_Ass.py
2659641 INFO: Processing pre-safe import module hook urllib3.packages.six.moves from 'C:\\Users\\Tarun\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-urllib3.packages.six.moves.py'.
27An error occurred while packaging
28Traceback (most recent call last):
29  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\auto_py_to_exe\packaging.py&quot;, line 131, in package
30    run_pyinstaller()
31  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\__main__.py&quot;, line 124, in run
32    run_build(pyi_config, spec_file, **vars(args))
33  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\__main__.py&quot;, line 58, in run_build
34    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
35  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\building\build_main.py&quot;, line 782, in main
36    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
37  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\building\build_main.py&quot;, line 714, in build
38    exec(code, spec_namespace)
39  File &quot;C:\Users\Tarun\AppData\Local\Temp\tmpjaw1ky1x\AI_Ass.spec&quot;, line 7, in &lt;module&gt;
40    a = Analysis(['C:/Users/Tarun/AppData/Local/Programs/Python/Python310/AI_Ass.py'],
41  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\building\build_main.py&quot;, line 277, in __init__
42    self.__postinit__()
43  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\building\datastruct.py&quot;, line 155, in __postinit__
44    self.assemble()
45  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\building\build_main.py&quot;, line 439, in assemble
46    priority_scripts.append(self.graph.add_script(script))
47  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py&quot;, line 265, in add_script
48    self._top_script_node = super().add_script(pathname)
49  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1433, in add_script
50    self._process_imports(n)
51  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2850, in _process_imports
52    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
53  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2301, in _safe_import_hook
54    target_modules = self.import_hook(
55  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1505, in import_hook
56    target_package, target_module_partname = self._find_head_package(
57  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1684, in _find_head_package
58    target_package = self._safe_import_module(
59  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py&quot;, line 387, in _safe_import_module
60    return super()._safe_import_module(module_basename, module_name, parent_package)
61  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2062, in _safe_import_module
62    self._process_imports(n)
63  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2850, in _process_imports
64    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
65  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2301, in _safe_import_hook
66    target_modules = self.import_hook(
67  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1505, in import_hook
68    target_package, target_module_partname = self._find_head_package(
69  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1684, in _find_head_package
70    target_package = self._safe_import_module(
71  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py&quot;, line 387, in _safe_import_module
72    return super()._safe_import_module(module_basename, module_name, parent_package)
73  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2062, in _safe_import_module
74    self._process_imports(n)
75  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2850, in _process_imports
76    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
77  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2301, in _safe_import_hook
78    target_modules = self.import_hook(
79  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1505, in import_hook
80    target_package, target_module_partname = self._find_head_package(
81  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1684, in _find_head_package
82    target_package = self._safe_import_module(
83  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py&quot;, line 387, in _safe_import_module
84    return super()._safe_import_module(module_basename, module_name, parent_package)
85  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2062, in _safe_import_module
86    self._process_imports(n)
87  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2850, in _process_imports
88    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
89  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2301, in _safe_import_hook
90    target_modules = self.import_hook(
91  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1505, in import_hook
92    target_package, target_module_partname = self._find_head_package(
93  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1684, in _find_head_package
94    target_package = self._safe_import_module(
95  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py&quot;, line 387, in _safe_import_module
96    return super()._safe_import_module(module_basename, module_name, parent_package)
97  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2062, in _safe_import_module
98    self._process_imports(n)
99  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2850, in _process_imports
100    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
101  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2301, in _safe_import_hook
102    target_modules = self.import_hook(
103  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1518, in import_hook
104    submodule = self._safe_import_module(head, mname, submodule)
105  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py&quot;, line 387, in _safe_import_module
106    return super()._safe_import_module(module_basename, module_name, parent_package)
107  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2062, in _safe_import_module
108    self._process_imports(n)
109  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2850, in _process_imports
110    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
111  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2301, in _safe_import_hook
112    target_modules = self.import_hook(
113  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1518, in import_hook
114    submodule = self._safe_import_module(head, mname, submodule)
115  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py&quot;, line 387, in _safe_import_module
116    return super()._safe_import_module(module_basename, module_name, parent_package)
117  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2062, in _safe_import_module
118    self._process_imports(n)
119  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2850, in _process_imports
120    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
121  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2301, in _safe_import_hook
122    target_modules = self.import_hook(
123  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 1518, in import_hook
124    submodule = self._safe_import_module(head, mname, submodule)
125  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\depend\analysis.py&quot;, line 387, in _safe_import_module
126    return super()._safe_import_module(module_basename, module_name, parent_package)
127  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2061, in _safe_import_module
128    n = self._scan_code(module, co, co_ast)
129  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2645, in _scan_code
130    self._scan_bytecode(
131  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py&quot;, line 2749, in _scan_bytecode
132    for inst in util.iterate_instructions(module_code_object):
133  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\util.py&quot;, line 147, in iterate_instructions
134    yield from iterate_instructions(constant)
135  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\util.py&quot;, line 139, in iterate_instructions
136    yield from get_instructions(code_object)
137  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\dis.py&quot;, line 338, in _get_instructions_bytes
138    argval, argrepr = _get_const_info(arg, constants)
139  File &quot;C:\Users\Tarun\AppData\Local\Programs\Python\Python310\lib\dis.py&quot;, line 292, in _get_const_info
140    argval = const_list[const_index]
141IndexError: tuple index out of range
142
143Project output will not be moved to output folder
144Complete.
145#importing libraries
146
147import speech_recognition as sr
148import pyttsx3
149import datetime
150import wikipedia
151import webbrowser
152import os
153import time
154import subprocess
155from   ecapture import ecapture as ec
156import wolframalpha
157import json
158import requests
159
160#setting up speech engine
161engine=pyttsx3.init('sapi5')
162voices=engine.getProperty('voices')
163engine.setProperty('voice','voices[1].id')
164
165def speak(text):
166    engine.say(text)
167    engine.runAndWait()
168    
169#Greet user
170def wishMe():
171    hour=datetime.datetime.now().hour
172    if hour&gt;=0 and hour&lt;12:
173        speak(&quot;Hello,Good Morning&quot;)
174        print(&quot;Hello,Good Morning&quot;)
175    elif hour&gt;=12 and hour&lt;18:
176        speak(&quot;Hello,Good Afternoon&quot;)
177        print(&quot;Hello,Good Afternoon&quot;)
178    else:
179        speak(&quot;Hello,Good Evening&quot;)
180        print(&quot;Hello,Good Evening&quot;)
181
182#Setting up the command function for your AI assistant
183def takeCommand():
184    r=sr.Recognizer()
185    with sr.Microphone() as source:
186        print(&quot;Listening...&quot;)
187        audio=r.listen(source)
188
189        try:
190            statement=r.recognize_google(audio,language='en-in')
191            print(f&quot;user said:{statement}\n&quot;)
192
193        except Exception as e:
194            speak(&quot;Pardon me, please say that again&quot;)
195            return &quot;None&quot;
196        return statement
197
198print(&quot;Loading your AI personal assistant Friday&quot;)
199speak(&quot;Loading your AI personal assistant Friday&quot;)
200wishMe()
201
202#main function
203if __name__=='__main__':
204
205
206    while True:
207        speak(&quot;Tell me how can I help you now?&quot;)
208        statement = takeCommand().lower()
209        if statement==0:
210            continue
211
212        if &quot;good bye&quot; in statement or &quot;ok bye&quot; in statement or &quot;stop&quot; in statement:
213            speak('your personal assistant Friday is shutting down,Good bye')
214            print('your personal assistant Friday is shutting down,Good bye')
215            break
216
217
218        if 'wikipedia' in statement:
219            speak('Searching Wikipedia...')
220            statement =statement.replace(&quot;wikipedia&quot;, &quot;&quot;)
221            results = wikipedia.summary(statement, sentences=10)
222            webbrowser.open_new_tab(&quot;https://en.wikipedia.org/wiki/&quot;+ statement)
223            speak(&quot;According to Wikipedia&quot;)
224            print(results)
225            speak(results)
226
227        elif 'open youtube' in statement:
228            webbrowser.register('chrome', None,
229        webbrowser.BackgroundBrowser(&quot;C://Program Files (x86)//Google//Chrome//Application//chrome.exe&quot;))
230            webbrowser.get('chrome').open_new_tab(&quot;https://www.youtube.com&quot;)
231            #webbrowser.open_new_tab(&quot;https://www.youtube.com&quot;)
232            speak(&quot;youtube is open now&quot;)
233            time.sleep(5)
234
235        elif 'open google' in statement:
236            webbrowser.open_new_tab(&quot;https://www.google.com&quot;)
237            speak(&quot;Google chrome is open now&quot;)
238            time.sleep(5)
239
240        elif 'open gmail' in statement:
241            webbrowser.open_new_tab(&quot;gmail.com&quot;)
242            speak(&quot;Google Mail open now&quot;)
243            time.sleep(5)
244        
245        elif 'time' in statement:
246            strTime=datetime.datetime.now().strftime(&quot;%H:%M:%S&quot;)
247            speak(f&quot;the time is {strTime}&quot;)
248
249        elif 'news' in statement:
250            news = webbrowser.open_new_tab(&quot;https://timesofindia.indiatimes.com/home/headlines&quot;)
251            speak('Here are some headlines from the Times of India,Happy reading')
252            time.sleep(6)
253
254        elif &quot;camera&quot; in statement or &quot;take a photo&quot; in statement:
255            ec.capture(0,&quot;robo camera&quot;,&quot;img.jpg&quot;)
256
257        elif 'search' in statement:
258            statement = statement.replace(&quot;search&quot;, &quot;&quot;)
259            webbrowser.open_new_tab(statement)
260            time.sleep(5)
261
262        elif 'who are you' in statement or 'what can you do' in statement:
263            speak('I am Friday version 1 point O your personal assistant. I am programmed to minor tasks like'
264            'opening youtube,google chrome, gmail and stackoverflow ,predict time,take a photo,search wikipedia,predict weather' 
265            'In different cities, get top headline news from times of india and you can ask me computational or geographical questions too!')
266
267
268        elif &quot;who made you&quot; in statement or &quot;who created you&quot; in statement or &quot;who discovered you&quot; in statement:
269            speak(&quot;I was built by Mirthula&quot;)
270            print(&quot;I was built by Mirthula&quot;)
271
272        elif &quot;log off&quot; in statement or &quot;sign out&quot; in statement:
273            speak(&quot;Ok , your pc will log off in 10 sec make sure you exit from all applications&quot;)
274            subprocess.call([&quot;shutdown&quot;, &quot;/l&quot;])
275            
276time.sleep(3)
27742681 INFO: PyInstaller: 4.6
27842690 INFO: Python: 3.10.0
279

There's the issue. Python 3.10.0 has a bug with PyInstaller 4.6. The problem isn't you or PyInstaller. Try converting it using Python 3.9.7 instead. Ironic, considering 3.10.0 was suppose to be a bugfix update.

Source https://stackoverflow.com/questions/69776492

QUESTION

Javascript: frame precise video stop

Asked 2022-Jan-28 at 14:55

I would like to be able to robustly stop a video when the video arrives on some specified frames in order to do oral presentations based on videos made with Blender, Manim...

I'm aware of this question, but the problem is that the video does not stops exactly at the good frame. Sometimes it continues forward for one frame and when I force it to come back to the initial frame we see the video going backward, which is weird. Even worse, if the next frame is completely different (different background...) this will be very visible.

To illustrate my issues, I created a demo project here (just click "next" and see that when the video stops, sometimes it goes backward). The full code is here.

The important part of the code I'm using is:

1      var video = VideoFrame({
2          id: 'video',
3          frameRate: 24,
4          callback: function(curr_frame) {
5              // Stops the video when arriving on a frames to stop at.
6              if (stopFrames.includes(curr_frame)) {
7                  console.log(&quot;Automatic stop: found stop frame.&quot;);
8                  pauseMyVideo();
9                  // Ensure we are on the proper frame.
10                  video.seekTo({frame: curr_frame});
11              }
12          }
13      });
14

So far, I avoid this issue by stopping one frame before the end and then using seekTo (not sure how sound this is), as demonstrated here. But as you can see, sometimes when going on the next frame it "freezes" a bit: I guess this is when the stop happens right before the seekTo.

PS: if you know a reliable way in JS to know the number of frames of a given video, I'm also interested.

Concerning the idea to cut the video before hand on the desktop, this could be used... but I had bad experience with that in the past, notably as changing videos sometimes produce some glitches. Also, it can be more complicated to use at it means that the video should be manually cut a lot of time, re-encoded...

EDIT Is there any solution for instance based on WebAssembly (more compatible with old browsers) or Webcodec (more efficient, but not yet wide-spread)? Webcodec seems to allow pretty amazing things, but I'm not sure how to use them for that. I would love to hear solution based on both of them since firefox does not handle webcodec yet. Note that it would be great if audio is not lost in the process. Bonus if I can also make controls appear on request.

EDIT: I'm not sure to understand what's happening here (source)... But it seems to do something close to my need (using webassembly I think) since it manages to play a video in a canvas, with frame... Here is another website that does something close to my need using Webcodec. But I'm not sure how to reliably synchronize sound and video with webcodec.

EDIT: answer to the first question

Concerning the video frame, indeed I chose poorly my frame rate, it was 25 not 24. But even by using a framerate of 25, I still don't get a frame-precise stop, on both Firefox and Chromium. For instance, here is a recording (using OBS) of your demo (I see the same with mine when I use 25 instead of 24):

enter image description here

one frame later, see that the butter "fly backward"(this is maybe not very visible with still screenshots, but see for instance the position of the lower left wing in the flowers):

enter image description here

I can see three potential reasons: first (I think it is the most likely reason), I heard that video.currentTime was not always reporting accurately the time, maybe it could explain why here it fails? It seems to be pretty accurate in order to change the current frame (I can go forward and backward by one frame quite reliably as far as I can see), but people reported here that video.currentTime is computed using the audio time and not the video time in Chromium, leading to some inconsistencies (I observe similar inconsistencies in Firefox), and here that it may either lead the time at which the frame is sent to the compositor or at which the frame is actually printed in the compositor (if it is the latest, it could explain the delay we have sometimes). This would also explain why requestAnimationVideoFrame is better, as it also provides the current media time.

The second reason that could explain that problem is that setInterval may not be precise enough... However requestAnimationFrame is not really better (requestAnimationVideoFrame is not available in Firefox) while it should fire 60 times per seconds which should be quick enough.

The third option I can see is that maybe the .pause function is quite long to fire... and that by the end of the call the video also plays another frame. On the other hand, your example using requestAnimationVideoFrame https://mvyom.csb.app/requestFrame.html seems to work pretty reliably, and it's using .pause! Unfortunately it only works in Chromium, but not in firefox. I see that you use metadata.mediaTime instead of currentTime, maybe this is more precise than current time.

The last option is that there is maybe something subtle concerning vsync as explained in this page. It also reports that expectedDisplayTime may help to solve this issue when using requestAnimationVideoFrame.

ANSWER

Answered 2022-Jan-21 at 19:18

The video has frame rate of 25fps, and not 24fps: enter image description here

After putting the correct value it works ok: demo
The VideoFrame api heavily relies on FPS provided by you. You can find FPS of your videos offline and send as metadata along with stop frames from server.


The site videoplayer.handmadeproductions.de uses window.requestAnimationFrame() to get the callback.


There is a new better alternative to requestAnimationFrame. The requestVideoFrameCallback(), allows us to do per-video-frame operations on video.
The same functionality, you domed in OP, can be achieved like this:

1      var video = VideoFrame({
2          id: 'video',
3          frameRate: 24,
4          callback: function(curr_frame) {
5              // Stops the video when arriving on a frames to stop at.
6              if (stopFrames.includes(curr_frame)) {
7                  console.log(&quot;Automatic stop: found stop frame.&quot;);
8                  pauseMyVideo();
9                  // Ensure we are on the proper frame.
10                  video.seekTo({frame: curr_frame});
11              }
12          }
13      });
14   const callback = (now, metadata) =&gt; {
15      if (startTime == 0) {
16        startTime = now;
17      }
18      elapsed = metadata.mediaTime;
19      currentFrame = metadata.presentedFrames - doneCount;
20
21      fps = (currentFrame / elapsed).toFixed(3);
22      fps = !isFinite(fps) ? 0 : fps;
23
24      updateStats();
25      if (stopFrames.includes(currentFrame)) {
26        pauseMyVideo();
27      } else {
28        video.requestVideoFrameCallback(callback);
29      }
30   };
31   video.requestVideoFrameCallback(callback);
32

And here is how demo looks like.
The API works on chromium based browsers like Chrome, Edge, Brave etc.


There is a JS library, which finds frame rate from video binary file, named mediainfo.js.

Source https://stackoverflow.com/questions/70613008

QUESTION

How to detect if a device can play Dolby Atmos Sound with Javascript

Asked 2021-Dec-24 at 06:57

I am looking for a way to detect if the device I am using can support Dolby Atmos sounds.

After searching around I found this call.

https://github.com/w3c/media-capabilities/blob/main/explainer.md#spatial-audio

1navigator.mediaCapabilities.decodingInfo({
2    type: 'file';
3    audio: {
4        // Determine support for Dolby Atmos by checking Dolby Digital Plus and spatial rendering.
5        contentType: &quot;audio/mp4; codecs=ec-3&quot;,
6        spatialRendering: true,
7    }
8}).then(result =&gt; {
9    // Do things based on results.
10    console.log(result.supported);
11    console.log(result.smooth);
12    console.log(result.powerEfficient);
13});
14

I guess this detects the codec the media was encoded with and if it support spatial audio.

Detecting the codec doesn't necessarily detect whether the system can support Dolby Atmos from what I understand the system needs to be connect to a receiver via a HDMI cable with arch support.

https://www.samsung.com/my/support/tv-audio-video/how-to-use-hdmi-arc-on-samsung-smart-tv/

The receiver needs to support multiple outputs to take the meta data sent from the codec parse through the HDMI arch and then the receiver knows which speaks to send the specific sounds too.

Something like this. https://www.richersounds.com/catalog/product/view/id/16007/s/denon-avcx8500h-black/

What reliable way is there to detect if your system will truly support Dolby Atmos whether its with a receiver or a Dolby Atmos compliant sound bar.

Any suggestions?

ANSWER

Answered 2021-Dec-24 at 06:57

Detecting the codec doesn't necessarily detect whether the system can support Dolby Atmos

Correct.

What reliable way is there to detect if your system will truly support Dolby Atmos whether its with a receiver or a Dolby Atmos compliant sound bar.

Unfortunately, this undetectable from the browser.

The browser itself and even the OS doesn't always know what is downstream. Sorry for the bad news!

Source https://stackoverflow.com/questions/70263091

QUESTION

FFMPEG's xstack command results in out of sync sound, is it possible to mix the audio in a single encoding?

Asked 2021-Dec-16 at 21:11

I wrote a python script that generates a xstack complex filter command. The video inputs is a mixture of several formats described here:

I have 2 commands generated, one for the xstack filter, and one for the audio mixing.

Here is the stack command: (sorry the text doesn't wrap!)

1'c:/ydl/ffmpeg.exe',
2'-i', 'inputX.mp4'
3'-i', 'inputX.mp4'
4'-i', 'inputX.mp4'
5'-i', 'inputX.mp4'
6'-i', 'inputX.mp4'
7'-i', 'inputX.mp4'
8'-i', 'inputX.mp4'
9'-i', 'inputX.mp4'
10'-i', 'inputX.mp4'
11'-i', 'inputX.mp4'
12'-i', 'inputX.mp4'
13'-i', 'inputX.mp4'
14'-i', 'inputX.mp4'
15'-i', 'inputX.mp4'
16'-i', 'inputX.mp4'
17'-filter_complex',
18'[0]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf0];[rsclbf0]fps=24[rscl0];[1]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf1];[rsclbf1]fps=24[rscl1];[2]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf2];[rsclbf2]fps=24[rscl2];[3]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf3];[rsclbf3]fps=24[rscl3];[4]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf4];[rsclbf4]fps=24[rscl4];[5]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf5];[rsclbf5]fps=24[rscl5];[6]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf6];[rsclbf6]fps=24[rscl6];[7]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf7];[rsclbf7]fps=24[rscl7];[8]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf8];[rsclbf8]fps=24[rscl8];[9]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf9];[rsclbf9]fps=24[rscl9];[10]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf10];[rsclbf10]fps=24[rscl10];[11]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf11];[rsclbf11]fps=24[rscl11];[12]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf12];[rsclbf12]fps=24[rscl12];[13]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf13];[rsclbf13]fps=24[rscl13];[14]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf14];[rsclbf14]fps=24[rscl14];[rscl0][rscl1][rscl2][rscl3][rscl4]concat=n=5[cct0];[rscl5][rscl6][rscl7]concat=n=3[cct1];[rscl8][rscl9][rscl10]concat=n=3[cct2];[rscl11][rscl12][rscl13][rscl14]concat=n=4[cct3];[cct0][cct1][cct2][cct3]xstack=inputs=4:layout=0_0|w0_0|0_h0|w0_h0',
19'output.mp4',
20

Here is the mix_audio command:

1'c:/ydl/ffmpeg.exe',
2'-i', 'inputX.mp4'
3'-i', 'inputX.mp4'
4'-i', 'inputX.mp4'
5'-i', 'inputX.mp4'
6'-i', 'inputX.mp4'
7'-i', 'inputX.mp4'
8'-i', 'inputX.mp4'
9'-i', 'inputX.mp4'
10'-i', 'inputX.mp4'
11'-i', 'inputX.mp4'
12'-i', 'inputX.mp4'
13'-i', 'inputX.mp4'
14'-i', 'inputX.mp4'
15'-i', 'inputX.mp4'
16'-i', 'inputX.mp4'
17'-filter_complex',
18'[0]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf0];[rsclbf0]fps=24[rscl0];[1]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf1];[rsclbf1]fps=24[rscl1];[2]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf2];[rsclbf2]fps=24[rscl2];[3]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf3];[rsclbf3]fps=24[rscl3];[4]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf4];[rsclbf4]fps=24[rscl4];[5]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf5];[rsclbf5]fps=24[rscl5];[6]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf6];[rsclbf6]fps=24[rscl6];[7]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf7];[rsclbf7]fps=24[rscl7];[8]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf8];[rsclbf8]fps=24[rscl8];[9]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf9];[rsclbf9]fps=24[rscl9];[10]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf10];[rsclbf10]fps=24[rscl10];[11]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf11];[rsclbf11]fps=24[rscl11];[12]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf12];[rsclbf12]fps=24[rscl12];[13]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf13];[rsclbf13]fps=24[rscl13];[14]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf14];[rsclbf14]fps=24[rscl14];[rscl0][rscl1][rscl2][rscl3][rscl4]concat=n=5[cct0];[rscl5][rscl6][rscl7]concat=n=3[cct1];[rscl8][rscl9][rscl10]concat=n=3[cct2];[rscl11][rscl12][rscl13][rscl14]concat=n=4[cct3];[cct0][cct1][cct2][cct3]xstack=inputs=4:layout=0_0|w0_0|0_h0|w0_h0',
19'output.mp4',
20'c:/ydl/ffmpeg.exe',
21'-i', 'inputX.mp4'
22'-i', 'inputX.mp4'
23'-i', 'inputX.mp4'
24'-i', 'inputX.mp4'
25'-i', 'inputX.mp4'
26'-i', 'inputX.mp4'
27'-i', 'inputX.mp4'
28'-i', 'inputX.mp4'
29'-i', 'inputX.mp4'
30'-i', 'inputX.mp4'
31'-i', 'inputX.mp4'
32'-i', 'inputX.mp4'
33'-i', 'inputX.mp4'
34'-i', 'inputX.mp4'
35'-i', 'inputX.mp4'
36'-i', 'inputX.mp4'
37'-filter_complex',
38'[0:a][1:a][2:a][3:a][4:a]concat=n=5:v=0:a=1[cct_a0];[5:a][6:a][7:a]concat=n=3:v=0:a=1[cct_a1];[8:a][9:a][10:a]concat=n=3:v=0:a=1[cct_a2];[11:a][12:a][13:a][14:a]concat=n=4:v=0:a=1[cct_a3];[cct_a0][cct_a1][cct_a2][cct_a3]amix=inputs=4[all_aud]',
39'-map',
40'15:v',
41'-map',
42'[all_aud]',
43'-c:v',
44'copy',
45'output.mp4',
46

Of course those are sample commands, I actually use many more videos as input, this sample is shorter for the sake or readability.

Here are the videos I use, with relevant ffprobe data, in some HTML table:

ffprobe data

I'm getting this warning:

1'c:/ydl/ffmpeg.exe',
2'-i', 'inputX.mp4'
3'-i', 'inputX.mp4'
4'-i', 'inputX.mp4'
5'-i', 'inputX.mp4'
6'-i', 'inputX.mp4'
7'-i', 'inputX.mp4'
8'-i', 'inputX.mp4'
9'-i', 'inputX.mp4'
10'-i', 'inputX.mp4'
11'-i', 'inputX.mp4'
12'-i', 'inputX.mp4'
13'-i', 'inputX.mp4'
14'-i', 'inputX.mp4'
15'-i', 'inputX.mp4'
16'-i', 'inputX.mp4'
17'-filter_complex',
18'[0]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf0];[rsclbf0]fps=24[rscl0];[1]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf1];[rsclbf1]fps=24[rscl1];[2]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf2];[rsclbf2]fps=24[rscl2];[3]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf3];[rsclbf3]fps=24[rscl3];[4]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf4];[rsclbf4]fps=24[rscl4];[5]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf5];[rsclbf5]fps=24[rscl5];[6]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf6];[rsclbf6]fps=24[rscl6];[7]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf7];[rsclbf7]fps=24[rscl7];[8]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf8];[rsclbf8]fps=24[rscl8];[9]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf9];[rsclbf9]fps=24[rscl9];[10]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf10];[rsclbf10]fps=24[rscl10];[11]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf11];[rsclbf11]fps=24[rscl11];[12]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf12];[rsclbf12]fps=24[rscl12];[13]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf13];[rsclbf13]fps=24[rscl13];[14]scale=480:270:force_original_aspect_ratio=decrease,pad=480:270:(ow-iw)/2:(oh-ih)/2, setsar=1[rsclbf14];[rsclbf14]fps=24[rscl14];[rscl0][rscl1][rscl2][rscl3][rscl4]concat=n=5[cct0];[rscl5][rscl6][rscl7]concat=n=3[cct1];[rscl8][rscl9][rscl10]concat=n=3[cct2];[rscl11][rscl12][rscl13][rscl14]concat=n=4[cct3];[cct0][cct1][cct2][cct3]xstack=inputs=4:layout=0_0|w0_0|0_h0|w0_h0',
19'output.mp4',
20'c:/ydl/ffmpeg.exe',
21'-i', 'inputX.mp4'
22'-i', 'inputX.mp4'
23'-i', 'inputX.mp4'
24'-i', 'inputX.mp4'
25'-i', 'inputX.mp4'
26'-i', 'inputX.mp4'
27'-i', 'inputX.mp4'
28'-i', 'inputX.mp4'
29'-i', 'inputX.mp4'
30'-i', 'inputX.mp4'
31'-i', 'inputX.mp4'
32'-i', 'inputX.mp4'
33'-i', 'inputX.mp4'
34'-i', 'inputX.mp4'
35'-i', 'inputX.mp4'
36'-i', 'inputX.mp4'
37'-filter_complex',
38'[0:a][1:a][2:a][3:a][4:a]concat=n=5:v=0:a=1[cct_a0];[5:a][6:a][7:a]concat=n=3:v=0:a=1[cct_a1];[8:a][9:a][10:a]concat=n=3:v=0:a=1[cct_a2];[11:a][12:a][13:a][14:a]concat=n=4:v=0:a=1[cct_a3];[cct_a0][cct_a1][cct_a2][cct_a3]amix=inputs=4[all_aud]',
39'-map',
40'15:v',
41'-map',
42'[all_aud]',
43'-c:v',
44'copy',
45'output.mp4',
46[swscaler @ 0000020bac5a19c0] Warning: data is not aligned! This can lead to a speed loss
47

I think this is unrelated to audio desyncing this unaligned data is about x264 resolutions being multiple of 16, but my filter takes this into account already.

There is a perceptible audio desyncing, which is the main problem I am having. FFMPEG doesn't seem to get other errors. Is it because I use 2 commands to mix the audio after? How could I proceed to to the xstack stage and the audio mixing in a single stage?

I'm a bit confused as how FFMPEG handles diverse framerates. I was told to reencode all the video inputs before performing the xstack stage, but I would create some disk overhead, so I'd rather do it in a single ffmpeg job it possible.

ANSWER

Answered 2021-Dec-16 at 21:11

I'm a bit confused as how FFMPEG handles diverse framerates

It doesn't, which would cause a misalignment in your case. The vast majority of filters (any which deal with multiple sources and make use of frames, essentially), including the Concatenate filter require that be the sources have the same framerate.

For the concat filter to work, the inputs have to be of the same frame dimensions (e.g., 1920⨉1080 pixels) and should have the same framerate.

(emphasis added)

The documentation also adds:

Therefore, you may at least have to add a ​scale or ​scale2ref filter before concatenating videos. A handful of other attributes have to match as well, like the stream aspect ratio. Refer to the documentation of the filter for more info.

You should convert your sources to the same framerate first.

Source https://stackoverflow.com/questions/70020874

QUESTION

How can I use value_counts() only for certain values?

Asked 2021-Nov-23 at 00:53

I want to extract how many positive reviews by brand are in a dataset which includes reviews from thousands of products. I used this code and I got a table including percentaje of positive and non-positive reviews. How can I get only the percentage of positive reviews by brand? I only want the "True" results in positive_review. Thanks!

1df_reviews_ok.groupby(&quot;brand&quot;)[&quot;positive_review&quot;].value_counts(normalize=True).mul(100).round(2)
2brand                   positive_review
3Belkin                  False               70.00
4                        True                30.00
5Bowers &amp; Wilkins        False               67.65
6                        True                32.35
7Corsair                 False               75.22
8                        True                24.78
9Definitive Technology   False               68.29
10                        True                31.71
11Dell                    False               60.87
12                        True                39.13
13DreamWave               False              100.00
14House of Marley         False              100.00
15JBL                     False               58.43
16                        True                41.57
17Kicker                  True                66.67
18                        False               33.33
19Lenovo                  False               76.92
20                        True                23.08
21Logitech                False               75.75
22                        True                24.25
23MEE audio               False               53.80
24                        True                46.20
25Microsoft               False               67.86
26                        True                32.14
27Midland                 False               72.09
28                        True                27.91
29Motorola                False               72.92
30                        True                27.08
31Netgear                 False               72.30
32                        True                27.70
33Pny                     False               68.78
34                        True                31.22
35Power Acoustik          False              100.00
36SVS                     False              100.00
37Samsung                 False               61.94
38                        True                38.06
39Sanus                   False               75.93
40                        True                24.07
41Sdi Technologies, Inc.  False               55.63
42                        True                44.37
43Siriusxm                False               73.33
44                        True                26.67
45Sling Media             False               67.16
46                        True                32.84
47Sony                    False               55.40
48                        True                44.60
49Toshiba                 False               56.52
50                        True                43.48
51Ultimate Ears           False               70.21
52                        True                29.79
53Verizon Wireless        False               75.86
54                        True                24.14
55WD                      False               58.33
56                        True                41.67
57Yamaha                  False               61.15
58                        True                38.85
59Name: positive_review, dtype: float64
60

ANSWER

Answered 2021-Nov-22 at 17:40

Using the following toy DataFrame as an example:

1df_reviews_ok.groupby(&quot;brand&quot;)[&quot;positive_review&quot;].value_counts(normalize=True).mul(100).round(2)
2brand                   positive_review
3Belkin                  False               70.00
4                        True                30.00
5Bowers &amp; Wilkins        False               67.65
6                        True                32.35
7Corsair                 False               75.22
8                        True                24.78
9Definitive Technology   False               68.29
10                        True                31.71
11Dell                    False               60.87
12                        True                39.13
13DreamWave               False              100.00
14House of Marley         False              100.00
15JBL                     False               58.43
16                        True                41.57
17Kicker                  True                66.67
18                        False               33.33
19Lenovo                  False               76.92
20                        True                23.08
21Logitech                False               75.75
22                        True                24.25
23MEE audio               False               53.80
24                        True                46.20
25Microsoft               False               67.86
26                        True                32.14
27Midland                 False               72.09
28                        True                27.91
29Motorola                False               72.92
30                        True                27.08
31Netgear                 False               72.30
32                        True                27.70
33Pny                     False               68.78
34                        True                31.22
35Power Acoustik          False              100.00
36SVS                     False              100.00
37Samsung                 False               61.94
38                        True                38.06
39Sanus                   False               75.93
40                        True                24.07
41Sdi Technologies, Inc.  False               55.63
42                        True                44.37
43Siriusxm                False               73.33
44                        True                26.67
45Sling Media             False               67.16
46                        True                32.84
47Sony                    False               55.40
48                        True                44.60
49Toshiba                 False               56.52
50                        True                43.48
51Ultimate Ears           False               70.21
52                        True                29.79
53Verizon Wireless        False               75.86
54                        True                24.14
55WD                      False               58.33
56                        True                41.67
57Yamaha                  False               61.15
58                        True                38.85
59Name: positive_review, dtype: float64
60df = pd.DataFrame({
61    'brand': list('AAAABBBB'),
62    'positive': [True, True, False, False, True, True, True, False]
63})
64

If you would like to get the percentage of positive reviews for each brand relative to the total number of reviews per brand then try:

1df_reviews_ok.groupby(&quot;brand&quot;)[&quot;positive_review&quot;].value_counts(normalize=True).mul(100).round(2)
2brand                   positive_review
3Belkin                  False               70.00
4                        True                30.00
5Bowers &amp; Wilkins        False               67.65
6                        True                32.35
7Corsair                 False               75.22
8                        True                24.78
9Definitive Technology   False               68.29
10                        True                31.71
11Dell                    False               60.87
12                        True                39.13
13DreamWave               False              100.00
14House of Marley         False              100.00
15JBL                     False               58.43
16                        True                41.57
17Kicker                  True                66.67
18                        False               33.33
19Lenovo                  False               76.92
20                        True                23.08
21Logitech                False               75.75
22                        True                24.25
23MEE audio               False               53.80
24                        True                46.20
25Microsoft               False               67.86
26                        True                32.14
27Midland                 False               72.09
28                        True                27.91
29Motorola                False               72.92
30                        True                27.08
31Netgear                 False               72.30
32                        True                27.70
33Pny                     False               68.78
34                        True                31.22
35Power Acoustik          False              100.00
36SVS                     False              100.00
37Samsung                 False               61.94
38                        True                38.06
39Sanus                   False               75.93
40                        True                24.07
41Sdi Technologies, Inc.  False               55.63
42                        True                44.37
43Siriusxm                False               73.33
44                        True                26.67
45Sling Media             False               67.16
46                        True                32.84
47Sony                    False               55.40
48                        True                44.60
49Toshiba                 False               56.52
50                        True                43.48
51Ultimate Ears           False               70.21
52                        True                29.79
53Verizon Wireless        False               75.86
54                        True                24.14
55WD                      False               58.33
56                        True                41.67
57Yamaha                  False               61.15
58                        True                38.85
59Name: positive_review, dtype: float64
60df = pd.DataFrame({
61    'brand': list('AAAABBBB'),
62    'positive': [True, True, False, False, True, True, True, False]
63})
64df.groupby('brand')['positive'].mean()
65

The result is as expected:

1df_reviews_ok.groupby(&quot;brand&quot;)[&quot;positive_review&quot;].value_counts(normalize=True).mul(100).round(2)
2brand                   positive_review
3Belkin                  False               70.00
4                        True                30.00
5Bowers &amp; Wilkins        False               67.65
6                        True                32.35
7Corsair                 False               75.22
8                        True                24.78
9Definitive Technology   False               68.29
10                        True                31.71
11Dell                    False               60.87
12                        True                39.13
13DreamWave               False              100.00
14House of Marley         False              100.00
15JBL                     False               58.43
16                        True                41.57
17Kicker                  True                66.67
18                        False               33.33
19Lenovo                  False               76.92
20                        True                23.08
21Logitech                False               75.75
22                        True                24.25
23MEE audio               False               53.80
24                        True                46.20
25Microsoft               False               67.86
26                        True                32.14
27Midland                 False               72.09
28                        True                27.91
29Motorola                False               72.92
30                        True                27.08
31Netgear                 False               72.30
32                        True                27.70
33Pny                     False               68.78
34                        True                31.22
35Power Acoustik          False              100.00
36SVS                     False              100.00
37Samsung                 False               61.94
38                        True                38.06
39Sanus                   False               75.93
40                        True                24.07
41Sdi Technologies, Inc.  False               55.63
42                        True                44.37
43Siriusxm                False               73.33
44                        True                26.67
45Sling Media             False               67.16
46                        True                32.84
47Sony                    False               55.40
48                        True                44.60
49Toshiba                 False               56.52
50                        True                43.48
51Ultimate Ears           False               70.21
52                        True                29.79
53Verizon Wireless        False               75.86
54                        True                24.14
55WD                      False               58.33
56                        True                41.67
57Yamaha                  False               61.15
58                        True                38.85
59Name: positive_review, dtype: float64
60df = pd.DataFrame({
61    'brand': list('AAAABBBB'),
62    'positive': [True, True, False, False, True, True, True, False]
63})
64df.groupby('brand')['positive'].mean()
65brand
66A    0.50
67B    0.75
68Name: positive, dtype: float64
69

Source https://stackoverflow.com/questions/70069983

QUESTION

Audio recording in Python with Pyaudio, error ||PaMacCore (AUHAL)|| ... msg=Audio Unit: cannot do in current context

Asked 2021-Nov-09 at 04:30

I am using pyaudio to record sounds on my Mac BigSur 11.6 (20G165). Specifically, I'm redirecting sound from an application to the input using BlackHole, which works fine.

It usually works fine but, sometimes, I get this error in the Terminal:

||PaMacCore (AUHAL)|| Error on line 2500: err='-10863', msg=Audio Unit: cannot do in current context

Any idea why or how I could prevent it from happening (like, waiting until PaMacCore is ready to record again or something)?

I already tried reinstalling but it doesn't help

1brew install portaudio
2

or

1brew install portaudio
2brew install portaudio --HEAD
3

Here's my code:

1brew install portaudio
2brew install portaudio --HEAD
3import pyaudio
4import wave
5
6
7class Recorder(object):
8    def __init__(self, fname, mode, channels,
9                 rate, frames_per_buffer):
10        self.fname = fname
11        self.mode = mode
12        self.channels = channels
13        self.rate = rate
14        self.frames_per_buffer = frames_per_buffer
15        self._pa = pyaudio.PyAudio()
16        self.wavefile = self._prepare_file(self.fname, self.mode)
17        self._stream = None
18
19    def __enter__(self):
20        return self
21
22    def __exit__(self, exception, value, traceback):
23        self.close()
24
25    def record(self, duration):
26        # Use a stream with no callback function in blocking mode
27        self._stream = self._pa.open(format=pyaudio.paInt16,
28                                     channels=self.channels,
29                                     rate=self.rate,
30                                     input=True,
31                                     frames_per_buffer=self.frames_per_buffer)
32        for _ in range(int(self.rate / self.frames_per_buffer * duration)):
33            audio = self._stream.read(self.frames_per_buffer)
34            self.wavefile.writeframes(audio)
35        return None
36
37    def start_recording(self):
38        # Use a stream with a callback in non-blocking mode
39        self._stream = self._pa.open(format=pyaudio.paInt16,
40                                     channels=self.channels,
41                                     rate=self.rate,
42                                     input=True,
43                                     frames_per_buffer=self.frames_per_buffer,
44                                     stream_callback=self.get_callback())
45        self._stream.start_stream()
46        return self
47
48    def stop_recording(self):
49        self._stream.stop_stream()
50        return self
51
52    def get_callback(self):
53        def callback(in_data, frame_count, time_info, status):
54            self.wavefile.writeframes(in_data)
55            return in_data, pyaudio.paContinue
56
57        return callback
58
59    def close(self):
60        self._stream.close()
61        self._pa.terminate()
62        self.wavefile.close()
63
64    def _prepare_file(self, fname, mode='wb'):
65        wavefile = wave.open(fname, mode)
66        wavefile.setnchannels(self.channels)
67        wavefile.setsampwidth(self._pa.get_sample_size(pyaudio.paInt16))
68        wavefile.setframerate(self.rate)
69        return wavefile
70

Usage example:

1brew install portaudio
2brew install portaudio --HEAD
3import pyaudio
4import wave
5
6
7class Recorder(object):
8    def __init__(self, fname, mode, channels,
9                 rate, frames_per_buffer):
10        self.fname = fname
11        self.mode = mode
12        self.channels = channels
13        self.rate = rate
14        self.frames_per_buffer = frames_per_buffer
15        self._pa = pyaudio.PyAudio()
16        self.wavefile = self._prepare_file(self.fname, self.mode)
17        self._stream = None
18
19    def __enter__(self):
20        return self
21
22    def __exit__(self, exception, value, traceback):
23        self.close()
24
25    def record(self, duration):
26        # Use a stream with no callback function in blocking mode
27        self._stream = self._pa.open(format=pyaudio.paInt16,
28                                     channels=self.channels,
29                                     rate=self.rate,
30                                     input=True,
31                                     frames_per_buffer=self.frames_per_buffer)
32        for _ in range(int(self.rate / self.frames_per_buffer * duration)):
33            audio = self._stream.read(self.frames_per_buffer)
34            self.wavefile.writeframes(audio)
35        return None
36
37    def start_recording(self):
38        # Use a stream with a callback in non-blocking mode
39        self._stream = self._pa.open(format=pyaudio.paInt16,
40                                     channels=self.channels,
41                                     rate=self.rate,
42                                     input=True,
43                                     frames_per_buffer=self.frames_per_buffer,
44                                     stream_callback=self.get_callback())
45        self._stream.start_stream()
46        return self
47
48    def stop_recording(self):
49        self._stream.stop_stream()
50        return self
51
52    def get_callback(self):
53        def callback(in_data, frame_count, time_info, status):
54            self.wavefile.writeframes(in_data)
55            return in_data, pyaudio.paContinue
56
57        return callback
58
59    def close(self):
60        self._stream.close()
61        self._pa.terminate()
62        self.wavefile.close()
63
64    def _prepare_file(self, fname, mode='wb'):
65        wavefile = wave.open(fname, mode)
66        wavefile.setnchannels(self.channels)
67        wavefile.setsampwidth(self._pa.get_sample_size(pyaudio.paInt16))
68        wavefile.setframerate(self.rate)
69        return wavefile
70recfile = Recorder(filename, 'wb', 2, 44100, 1024)
71recfile.start_recording()
72...
73recfile.stop_recording()
74

ANSWER

Answered 2021-Nov-03 at 16:29

Apparently the problem were mismatched bitrates in BlackHole's aggregated output device. I was aggregating Blackhole's output (44,1kHz) and the Mac Speakers (48kHz). This did not cause any consistent bad behaviour but sometimes led to these errors.

Source https://stackoverflow.com/questions/69571374

QUESTION

Java mp4parser to create a single .m4s fragment— invalid moov box

Asked 2021-Oct-22 at 06:01

This use case is a service that manually encodes a series of uncompressed .wav media segments into .m4s fragments for broadcast via MPEG-DASH, using ffmpeg to compress the .wav to .aac and sannies/mp4parser to assemble the aac audio into an .m4s media fragment.

I created this public GitHub project to reproduce the issue in its entirety.

For example, here's the custom CustomFragmentMp4Builder.java class.

It's critical that we be able to designate this single .m4s fragment with a sequence number (index) that we will manually increment for each media segment.

The objective is to build an .m4s fragment comprising the box types SegmentTypeBox, SegmentIndexBox, and MovieFragmentBox. As For reference, I have used mp4parser to inspect an .m4s fragment that was generated via ffmpeg -f hls. This specification is available here as a .yaml file

My implementation creates an MP4 without error. But, when the unit test attempts to read the file that the ChunkMp4Builder just wrote to a temp folder:

1java.lang.RuntimeException: A cast to int has gone wrong. Please contact the mp4parser discussion group (3724673092)
2    at org.mp4parser.tools.CastUtils.l2i(CastUtils.java:30)
3    at org.mp4parser.support.AbstractBox.parse(AbstractBox.java:97)
4    at org.mp4parser.AbstractBoxParser.parseBox(AbstractBoxParser.java:116)
5    at org.mp4parser.BasicContainer.initContainer(BasicContainer.java:107)
6    at org.mp4parser.IsoFile.&lt;init&gt;(IsoFile.java:57)
7    at org.mp4parser.IsoFile.&lt;init&gt;(IsoFile.java:52)
8    at com.charneykaye.TestBase.getMp4Boxes(TestBase.java:116)
9    at com.charneykaye.CustomFragmentMp4BuilderTest.run(CustomFragmentMp4BuilderTest.java:78)
10

The expected box types SegmentTypeBox, SegmentIndexBox, and MovieFragmentBox do appear in the output:

The expected box types SegmentTypeBox, SegmentIndexBox, and MovieFragmentBox do appear in the output

However, at the end of the file appears a box of an unknown type:

There seems to be a box of an unknown type, appearing at the end of the file.

ANSWER

Answered 2021-Oct-21 at 20:57

Your m4s segments are invalid due to an incorrect mdat atom size.

For example in test5-128k-151304042.m4s the mdat is marked as having a length of 16 bytes but there is data at the end and file size is 164884.

The parser then attempts to read an invalid offset. avc5 is not an atom but actually part of the string "Lavc58.54.100". The length read as 3724673100 is also invalid and greater than the max for a 32-bit integer, hence the invalid cast to int.

hex dump


In your implementation you have:

1java.lang.RuntimeException: A cast to int has gone wrong. Please contact the mp4parser discussion group (3724673092)
2    at org.mp4parser.tools.CastUtils.l2i(CastUtils.java:30)
3    at org.mp4parser.support.AbstractBox.parse(AbstractBox.java:97)
4    at org.mp4parser.AbstractBoxParser.parseBox(AbstractBoxParser.java:116)
5    at org.mp4parser.BasicContainer.initContainer(BasicContainer.java:107)
6    at org.mp4parser.IsoFile.&lt;init&gt;(IsoFile.java:57)
7    at org.mp4parser.IsoFile.&lt;init&gt;(IsoFile.java:52)
8    at com.charneykaye.TestBase.getMp4Boxes(TestBase.java:116)
9    at com.charneykaye.CustomFragmentMp4BuilderTest.run(CustomFragmentMp4BuilderTest.java:78)
10ParsableBox moov = createMovieFragmentBox(movie);
11isoFile.addBox(moov);
12List&lt;SampleSizeBox&gt; stszs = Path.getPaths(moov, &quot;trak/mdia/minf/stbl/stsz&quot;);
13// ...
14
15protected MovieFragmentBox createMovieFragmentBox(Movie movie) {
16    MovieFragmentBox mfb = new MovieFragmentBox();
17    // ...
18}
19

This is not a moov atom, it's a moof. There is no stsz in there and the sum of your sample sizes is 0 so the total calculated size of the mdat is 16 + 0.

The moov is supposed to be in the initialization segment.

Source https://stackoverflow.com/questions/69625970

QUESTION

Node.js - Client to Server WebRTC with P2P

Asked 2021-Aug-26 at 04:13

After looking to implement WebRTC with a Client to Server model (like Discord), I came to the conclusion that the way to do this is to have 2 clients - the server and client. Audio streams can be overlayed and sent back to the user in 1 single stream.

backend/server.js

1const clientPeer = new Peer({ initiator: true, wrtc });
2    
3clientPeer.on('connect', () =&gt; console.log('hi client, this is server'));
4clientPeer.on('data', (data) =&gt; console.log('got a message from client peer: ', data));
5

frontend/index.js

1const clientPeer = new Peer({ initiator: true, wrtc });
2    
3clientPeer.on('connect', () =&gt; console.log('hi client, this is server'));
4clientPeer.on('data', (data) =&gt; console.log('got a message from client peer: ', data));
5serverPeer.on('connect', () =&gt; console.log('Connected to server'));
6serverPeer.on('stream', async (stream) =&gt; {
7  const video = document.createElement('audio');
8
9  ('srcObject' in video)
10    ? video.srcObject = stream
11    : video.src = window.URL.createObjectURL(stream);
12
13  await video.play();
14});
15

How would I implement sending media streams between the client and server?

ANSWER

Answered 2021-Aug-26 at 04:13

A possible solution can be: Create a MediaRecorder object, which can record the media streams on the client-side. This object emits data chunks over time. You can send these chunks via WebSocket to the server. On the server side, you can do what you want with the data chunks. For more details, you can check this https://mux.com/blog/the-state-of-going-live-from-a-browser/.

https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder Another solution can be: Making a node.js application a PEER with WebRTC

Source https://stackoverflow.com/questions/68821533

Community Discussions contain sources that include Stack Exchange Network

Tutorials and Learning Resources in Audio

Tutorials and Learning Resources are not available at this moment for Audio

Share this Page

share link

Get latest updates on Audio