ESP8266, Wifi + clap on/off HELP

Hi. I have made a code for a project, but im stuck somewhere? I can upload my code to my esp without any errors, but only the wifi piece is working, it will not detect claps? I think the esp is stuck somwhere in the code?

#include <ESP8266WiFi.h>
#define Rele D2
int ledPin = 4;
int soundPin = A0;
int clapCount = 0;
int state = 0;
int klapp = 0;
unsigned long tid_siden_reset = 0; // Unsigned long - utvida størrelsesvariablar for talllagring, vil ikkje lagra negative tall
unsigned long tid_siden_reset1 = 0;
int interval = 1500; // Setter første interval til 1,5sekund
int interval1 = 5000; // Denna skal endrast

const char* ssid = "BjornMa";
const char* password = "kjetilgutt";
unsigned char status_Rele=0;
WiFiServer server(80);

void setup() {
Serial.begin(115200);
pinMode(Rele, OUTPUT);
Serial.println();
Serial.print("Connecting to ");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
server.begin();
Serial.println("Server started");
Serial.println(WiFi.localIP());

}

void loop() {
WiFiClient client = server.available();
if (!client) {
return;
}

Serial.println("new client");
while(!client.available())
{
delay(1);
}
int soundState = analogRead(soundPin); //
if (soundState > 400) {
Serial.print("klapp \n");
delay(100);

tid_siden_reset = millis();

tidsinterval();

klapp = clapCount;
Serial.println(klapp);

teller();

}
if (klapp == 1 && state == 0) {
digitalWrite(Rele, HIGH);
Serial.print("LED paa \n");

clapCount = 0;
klapp = 0;
state = 1;

}
if (klapp == 1 && state == 1) {
digitalWrite(Rele, LOW);
Serial.print("LED av \n");

clapCount = 0;
klapp = 0;
state = 0;

}
if (klapp == 2 && state == 0) {
tid_siden_reset1 = millis();

while ((millis() - tid_siden_reset1) < interval1) {
digitalWrite(Rele, HIGH);

}
digitalWrite(Rele, LOW);

clapCount = 0;
klapp = 0;
state = 0;

}
String req = client.readStringUntil('\r');
Serial.println(req);
client.flush();
if (req.indexOf("/off") != -1)
{
status_Rele=0;
digitalWrite(Rele,LOW);
Serial.println("Rele av");
}
else if(req.indexOf("/on") != -1)
{
status_Rele=1;
digitalWrite(Rele,HIGH);
Serial.println("Rele paa");
}
}

/*************************************/
void tidsinterval() {

while ((millis() - tid_siden_reset) < interval) { //interval = 1,5sekund
int soundState1 = analogRead(soundPin);
if (soundState1 > 400) {
Serial.print("endo eit klapp \n");
clapCount++;

delay(200);
}
}
}

/************************************/
void teller() {
if (klapp >= 3) {
Serial.print("resetta klapp (meir)\n");
clapCount = 0;

delay(5000);

}
else if (klapp == 0) {
Serial.print("resetta klapp (mindre)\n");
clapCount = 0;

}
}

I have made a code for a project, but im stuck somewhere?

If you don't know if you are stuck, we certainly can't help you.

Why are you starting ANOTHER thread?

void loop() {
   WiFiClient client = server.available();
  if (!client) {
    return;
  }

If there is no client, do nothing. You can clap until hell freezes over and all you'll get is sore hands.