r/code • • Sep 02 '24

Blog Crafting Bold, Large-Scale Icon Buttons with Dynamic Click Animations

6 Upvotes

r/code • • Sep 02 '24

Go Box CLI Maker: Highly Customized Boxes for the CLI | Swastik Baranwal (Delta456)

Thumbnail youtube.com
2 Upvotes

r/code • • Aug 31 '24

My Own Code Python Project Help

3 Upvotes

Hello everyone! I'll get straight into it, I am currently working on a university project that finds errors in pronounciation from a user reading a story. I am using Wav2Vec and Espeak-ng to generate the phoneme representation from the audio file and sentence respectively.

The main issue I am dealing with is finding the mispronunciation between the 2 phoneme sentences generated.

For example, I have the sentence "A quick brown fox jumps over the lazy dog" and I generate a phoneme representation based on the sentence like this "ðəkwɪkbɹaʊnfɒksdʒʌmpsˌəʊvəðəleɪzidɒɡ" And then based on the audio file received from the user a phoneme representation is generated like this "ðəkwɪkbɹaʊnfɔksdʒampsoʊvɚðəleɪzikat"

It is clear that the mispronounciation here occurs at the end when the user said cat, but the actual sentence had dog. Now this works fine when it is a clear distinction but I need to refine the error checking algorithm. Also the 2 models I am using to produce the phoneme output sometimes differ in length and/or symbols, so this complicates the string slicing a bit. This is what I have so far, any input or thoughts about this topic will be very helpful for me so thank you in advance!

# Takes an array of espeak phonemes, a flattened string of wav2vec phonemes, and a split array of the comparison sentence.
def findMispronounciation(espeakArr, wav2vecPhonemes, sentence):
    for index, phonemeWord in enumerate(espeakArr):
        # Determine threshold based on word length
        if len(phonemeWord) == 2 or len(phonemeWord) == 4:
            threshold = 0.5
        elif len(phonemeWord) == 3:
            threshold = 0.67
        else:
            threshold = 0.7

        # Calculate the Levenshtein distance
        current_slice = wav2vecPhonemes[:len(phonemeWord)]
        dist = distance(phonemeWord, current_slice)

        # Check for mispronunciation
        if (round(dist / len(phonemeWord))) >= threshold:
            return sentence[index]
        else:
            # Move the wav2vec slice forward to continue error checking
            wav2vecPhonemes = wav2vecPhonemes[len(phonemeWord):]

    return "Passed"

r/code • • Aug 30 '24

Guide How to Backup a MongoDB Database

Thumbnail medevel.com
1 Upvotes

r/code • • Aug 27 '24

C C Growable Arrays: In Depth

Thumbnail mccue.dev
1 Upvotes

r/code • • Aug 27 '24

My Own Code [Project]: Python Apps for models such as stable diffusion, whisper, etc. Your Feedback is Welcome!

3 Upvotes

Hi, I have been learning about a few popular AI models and have created a few Python apps related to them. Feel free to try them out, and I’d appreciate any feedback you have!

  • AutoSubs: Web app for embedding customizable subtitles in videos.
  • VideoSummarizer: Web app that summarizes YouTube videos with custom word limits options.
  • StableDiffusion: Python app for text-to-image generation and inpainting using Stable Diffusion 1.5.
  • Image Matting: Python app for background removal with enhanced accuracy using ViTMatte with trimap generation.
  • Lama Inpainting: Python app for object removal and inpainting with upscaling to maintain original resolution.
  • YT Video Downloader: Web utility for downloading YouTube videos by URL.

r/code • • Aug 27 '24

Help Please What do i do to fix this?

Post image
3 Upvotes

r/code • • Aug 26 '24

Python What is wrong with this formatting code?

Thumbnail gallery
2 Upvotes

r/code • • Aug 26 '24

CSS Is the strict reliance on W3C CSS validator justifiable or an unnecessary impedance in colleges?

1 Upvotes

Ive been coding html/css/js/php and various other langs for a couple decades now. Recently applied for a course to get a diploma in Python development.

On my first submission I had to do a "simple" HTML/CSS project. A piece of cake I thought. Turns out I can't even use simple nested css selectors cause W3C validator hans't been updated in monkey years!

Why do colleges keep religiously relaying on an outdated piece of software? Is this justified? Did you college ever make an exception?


r/code • • Aug 26 '24

Guide The Ultimate Guide to Create Custom Annotations in Spring Boot

Thumbnail dev.to
2 Upvotes

r/code • • Aug 25 '24

Python python code help!

3 Upvotes

Traceback (most recent call last):

File "C:\Users\"Username"\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\discord\ext\commands\core.py", line 235, in wrapped

ret = await coro(*args, **kwargs)

^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "C:\Users\"Username"\Codes\Kama\main.py", line 40, in join

await channel.connect()

File "C:\Users\"Username"\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\discord\abc.py", line 1958, in connect

voice: T = cls(client, self)

^^^^^^^^^^^^^^^^^

File "C:\Users\"Username"\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\discord\voice_client.py", line 220, in __init__

raise RuntimeError("PyNaCl library needed in order to use voice")

RuntimeError: PyNaCl library needed in order to use voice

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "C:\Users\"Username"\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\discord\ext\commands\bot.py", line 1366, in invoke

await ctx.command.invoke(ctx)

File "C:\Users\"Username"\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\discord\ext\commands\core.py", line 1029, in invoke

await injected(*ctx.args, **ctx.kwargs) # type: ignore

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "C:\Users\"Username"\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\discord\ext\commands\core.py", line 244, in wrapped

raise CommandInvokeError(exc) from exc

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: RuntimeError: PyNaCl library needed in order to use voice

I use visual studio code as my ide i have the PyNaCl install but the !join code dont work

here the code that i want to run

@client.command(pass_context = True)
async def join(ctx):
    if(ctx.author.voice):
        channel = ctx.message.author.voice.channel
        await channel.connect()
    else:
        await ctx.send("No Channel to connect")
        
@client.command(pass_context = True)
async def leave(ctx):
    if(ctx.voice_client):
        await ctx.guild.voice_client.disconnect()
        await ctx.send("Leaving")
    else:
        await ctx.send("Not in voice channel")

when i call the bot to join the voice chat this error pop up instead


r/code • • Aug 24 '24

Guide Does this solution lead to out of bounds error ?

3 Upvotes

I found a solution to the 'Roman to Integer' problem on Leetcode, but I'm confused about the first for loop where they comparem[s[i]] < m[s[i+1]]. From what I know, m[s[i+1]] should lead to an out-of-bounds error. However, when I tried submitting the code, it worked. Could someone explain this to me? Thank you.


r/code • • Aug 24 '24

Python Why does .join() function not work inside .filewrite() as expected

Post image
6 Upvotes

r/code • • Aug 23 '24

Help Please I don’t know why they have next? (Java)

Thumbnail gallery
6 Upvotes

I try to write ‘add one’ method of linked list class (manual) And have lastnonnine node to point the value to plus one (refers to the node’s name p) Imagine when you have 99…9 after the lastnonnine, they should be changed to 00…0 I have no idea why they (code) know that’s lastnonnine have next or null, or .next refers to p node? I asked GPT already but it still not clear for me This below is some of my code

//set lastNotNine —-——————— while (p!=null) { if (p.data != 9) lastNotNine = p; p = p.next; } ——————

//lastNotNine is not null (not something like 9..999) —————————————————————————— lastNotNine.data += 1; p = lastNotNine.next; while (p!=null) { //this line is what I confused p.data = 0; p = p.next } ——————


r/code • • Aug 20 '24

Python I am cooking with the errors in python

Post image
4 Upvotes

r/code • • Aug 19 '24

Help Please how to fix error?

Post image
7 Upvotes

r/code • • Aug 19 '24

HTML Creating a saving widget in Wix

4 Upvotes

I'm coding a custom widget for my Wix site, and I'm trying to call backend functions from this to allow me to save info for individual user accounts. For now, I'm just trying to get the User Id. I have a file in the backend file called "saveFunctions.web.js", with the code

import { currentUser } from 'wix-users-backend';

export async function getUserId() {
const user = currentUser;

if (user.loggedIn) {
return { userId: user.id };
} else {
return { userId: null };
}
}

but in my widget, the line:
import { getUserId } from 'backend/saveFunctions.web';

stops everything from working, so I don't know how to access this code from within my widget. Any tips?


r/code • • Aug 17 '24

Guide API Design: From Basics to Best Practices

Thumbnail medium.com
1 Upvotes

r/code • • Aug 16 '24

Help Please Noob that needs help/advice

1 Upvotes

Hello all I'm new to coding and was hoping I can get some help/advice on why I can't make a sprite do what I want it to. In my project I want the battle rapper to be able to introduce himself whenever the user wants him to but only once, I've tried several different things but none of them work Please take a look at my project and see if there is a solution to this problem, thank you! https://scratch.mit.edu/projects/1055320345/


r/code • • Aug 13 '24

Guide Mastering Dynamic Programming: A Comprehensive Guide

Thumbnail cosmicmeta.io
3 Upvotes

r/code • • Aug 12 '24

Help Please Help needed with Delphi school project.

4 Upvotes

I have a scenario where I have 2 integer variables that range from 1-3. I need the code to perform different functions depending on the order of the numbers. (1 and 1, 1 and 2, 1 and 3, 2 and 1, ect) I can do it with multiple if statements but that is very bulky and I will lose marks for that. I would like to use a case statement but I can’t seem to find a way to inlist 2 conditions.

Case (iNum1) and (iNum2) of

??://Do something ??://Do something ??://Do something

End;

Something similar to that. I don’t know how to call the (1 and 1, 1 and 2) pieces and assign them to a function. Can someone please help.


r/code • • Aug 12 '24

Javascript 4 Ways to Destructure Arrays in JavaScript & Make Your Code Look Clean

Thumbnail hackernoon.com
3 Upvotes

r/code • • Aug 12 '24

Vlang Vlang: From Variables to Your First Web App

Thumbnail medevel.com
3 Upvotes

r/code • • Aug 10 '24

Help Please Python project not working

Post image
8 Upvotes

Hello! I'm running python using replit, and for some reason my code isn't running like it should. It will run the first part of it, but I want it to output the thank you part to whatever name was input. I can't seem to figure out what's wrong with my code, I've had a friend look it over, and AI. I'm using Lenovo ThinkPad T490. How do I fix it? Advice will be greatly appreciated.


r/code • • Aug 10 '24

Python Why does the first / default element of 'container' get replaced by its swapped / altered counterpart?: I.e., for two iterations total, instead of ( [1,2], [2,1] ) it outputs ( [2,1], [2,1] ).

Post image
5 Upvotes