šļøšÆ ××××× ××××ר ××¢×ר××Ŗ ā ××× ×, ×××××Ŗ×, ×××××§!!
-
××× ××ש×××Ŗ ×¢× ×××× ××××× ××××ר...
×ר×× ×¤×¢××× ××× ××× × ×ער×××Ŗ - ר×צ×× ×ש×× ××××× ××××ר, ××××× × ×©×שת×ש ×××× ×ש××× ××§××× ×שרת ××שרת ××Ŗ××× ××Ŗ ×××§×××.
××××Ŗ ××ש×× ×צ××¢×× ×××× ×××, ×××××Ŗ ש××£ ×¤×¢× ×× × ××”××Ŗ× ×××Ŗ×, ×× ×©×× × ×× ××××¢ ×× ×Ø××Ŗ ××××××Ŗ ש××...
××× ×× ××¢×××Ŗ ××××××Ŗ, ×××ר×× ×שת×ש×× ×× ×הפ××§ ×”××× ××× ×× ×”××Ŗ ××צ×× ××××Ø× ××××,
(×××××× ×××§×”× × ×©×× ×שרת - ×× ××× ×©×שרת ×× ××צע ×× ××Ŗ ××Ŗ×××× ×עצ××?!)×ש ×©×Ŗ× ×”×¤×Ø×××Ŗ ×××ר××Ŗ ××××××Ŗ ××Ŗ×××× ×©××Ŗ××× ××¢×ר××Ŗ,
××× ×©× ×××× - ×הפר×××
SpeechRecognition
×××× ×©× ×××קר××”××¤× - ×הפר×××Whisper
× Whisper ×ש ××תר×× ×ש××¢××Ŗ× - ש×פשר ×××ר×× ××××©× ××× ×¦××Ø× ×××××ר ×××× ××Ø× ×, ××× ×××× ×©××××× ×Ø×× ×ש×××ש ××××× × ×¢×©× ×××Ø× ××× ×שרת ××××' ×× ×××תר×× ×× ×× ×× ×ש××¢××Ŗ×...
××× × ×××ר ××××§××Ŗ ××Ŗ×¢×××Ŗ... ×××¢×Ŗ× ×××”×§× × ×©××××× ×©× ××××, ×× ×Ø××× ××Ŗ ×××× ×©× ×××קר××”×פ×...
×ש×× ××××ר ש×××§××× ××”××£ ××××¢× ××××××Ŗ ×©× ××פ××... ××× ×©× ×§×× ×× ×”×Ø ××××¤× ×... ×××× ×ש×× ×©××××× ××××¢ ×××××Ŗ ××Ŗ ×××××ר ×× ××Ŗ× ××× ×§×©×× ××× ×Ø×¢×©× ×Ø×§×¢, ×××××Ŗ ×ר×××, ×××'...
×× × ×××©× ×©××××× ×©× ×××× ××× ××××××§ ××××××Ŗ× ×××¢× ××× ××¢××××Ŗ... ×××××Ŗ× ××××ׄ ××× ×× ×©×Ø××¦× ×ער××Ŗ ×××××Ŗ××Ŗ, ××שת×ש ××...
×× ×¦×Ø×× ××¤×Ŗ× API !
×× × ×Ø××¦× ××××”××£ ××××¦× ×× ×”××× ×ר×× ××× ×שת××©×Ŗ× ×¢× ×× ××ש×× ×× ×××Ŗ××× ×××”××£ ×©× ×××§××× ×× ××××... ×××©× ×××§×× "××× ×©×Ŗ××× ×©××ש ×ר××¢" ××× ×××× "× ×©×Ŗ××× ×©××ש ×ר"- ×¢× ×©××× ×Ŗ× ×©××××× ××× × ××× ××× ××× ×פע××× ××Ŗ×××Ŗ ×××§××× ××”××£ ×××§××× × ××Ŗ× (××ש ××××××× ×©× ×©× ×××) ×××× ×× ×Ø×צ×× ×ש××× ××§××× ×ר××× ×שרת, ×××©× ××©×¤× ×©×× ×××' ×× ×× ×××Ø× ××× ×× ×× ×× ××¢××...
××× ×× ×Ø×צ×× ×ש××× ×××× ×××Ŗ ××××' ×× ×× ×××× ×××××Ŗ ×××× ×ש××¢××Ŗ×.... ××× ××××ׄ (×× ×”×××! ×× ×¤×תר ××Ŗ ×××¢×××!) ××××”××£ ×©× ××× ×©×§× ××Ŗ××××Ŗ ××”××£ ×××§××× ××××ר ×××Ø× ×©××× × ×©×××Ŗ ×שרת, ××¤× × ×©×××× ××¢×× ××Ŗ ×××§××× ××××ׄ ××Ŗ ××Ŗ××××... - ××שת×ש ×¢× ×הפר×××pydub
××× ××××”××£ ×©× ××× ×©×§× ×Ŗ×××× ××”××£...
(צר×× ×××××§ ש-FFmpeg
×××Ŗ×§× ××”××××, ××רת ×הפר××× ×× ×Ŗ×¢×××)×¢×× ×ש××...
×פע××× ×× ×× × ××××¢×× ×ר×ש ×× ××פשר××××Ŗ ש××שת×ש ×××× ×××ר ā
×××©× ×©×××Ŗ ×©× ×¢×Ø××:×× × ×רק, ×ר×ש×××, ×Ŗ× ××××, ××פ×, ×ש×××, ×××'...
×פשר ×עש××Ŗ ש××§×× ×××× ××Ŗ ×××××ר ×××צע ××Ŗ×××
×××©× ×× ××××× ×××× "×ר×ש×××" ×× ××× ××Ŗ××× ××ר×ש×××...×× × ×צרף ×¤× ×§×× ×¤×××Ŗ×× ××××××:
×××× ×¦×Ø×× ×¢×× ××× ×©×× ×××× ××× ×©××Ŗ××× ×××××Ŗ ××ש××...import os import tempfile import logging import requests from flask import Flask, request, jsonify from pydub import AudioSegment import speech_recognition as sr from rapidfuzz import process, fuzz # ------------------ Logging Configuration ------------------ logging.basicConfig( level=logging.INFO, format="%(asctime)s | %(levelname)s | %(message)s", datefmt="%H:%M:%S" ) app = Flask(__name__) # List of possible keywords to match KEYWORDS = ["×× × ×רק", "×ר×ש×××", "×Ŗ× ××××", "××פ×", "×ש×××"] # ------------------ Helper Functions ------------------ def add_silence(input_path: str) -> AudioSegment: """ Add one second of silence at the beginning and end of the audio file. This improves speech recognition accuracy, especially for short recordings. """ logging.info("Adding one second of silence to audio file...") audio = AudioSegment.from_file(input_path, format="wav") silence = AudioSegment.silent(duration=1000) # 1000ms = 1 second return silence + audio + silence def recognize_speech(audio_segment: AudioSegment) -> str: """ Perform speech recognition using Google SpeechRecognition API. """ recognizer = sr.Recognizer() try: # Use a temporary file for SpeechRecognition to read with tempfile.NamedTemporaryFile(suffix=".wav", delete=True) as temp_wav: audio_segment.export(temp_wav.name, format="wav") with sr.AudioFile(temp_wav.name) as source: data = recognizer.record(source) text = recognizer.recognize_google(data, language="he-IL") logging.info(f"Recognized text: {text}") return text except sr.UnknownValueError: logging.warning("Speech not detected or unclear.") return "" except Exception as e: logging.error(f"Error during speech recognition: {e}") return "" def find_best_match(text: str) -> str | None: """ Find the closest matching word from the predefined KEYWORDS list. """ if not text: return None result = process.extractOne(text, KEYWORDS, scorer=fuzz.ratio) if result and result[1] >= 80: logging.info(f"Best match found: {result[0]} (confidence: {result[1]}%)") return result[0] logging.info("No sufficient match found.") return None # ------------------ API Endpoint ------------------ @app.route("/upload_audio", methods=["GET"]) def upload_audio(): """ Endpoint to receive an audio file via GET parameter, download it, process it, and return the recognized text with the best match. Example usage: /upload_audio?file_url=https://example.com/audio.wav """ file_url = request.args.get("file_url") if not file_url: logging.error("Missing 'file_url' parameter.") return jsonify({"error": "Missing 'file_url' parameter"}), 400 logging.info(f"Received file URL: {file_url}") try: # Step 1: Download the audio file response = requests.get(file_url, timeout=15) if response.status_code != 200: logging.error(f"Failed to download audio file. Status code: {response.status_code}") return jsonify({"error": "Failed to download audio file"}), 400 with tempfile.NamedTemporaryFile(suffix=".wav", delete=True) as temp_input: temp_input.write(response.content) temp_input.flush() logging.info(f"Audio downloaded and saved temporarily: {temp_input.name}") # Step 2: Add silence processed_audio = add_silence(temp_input.name) # Step 3: Speech recognition recognized_text = recognize_speech(processed_audio) # Step 4: Matching against predefined keywords matched_word = find_best_match(recognized_text) if matched_word: logging.info(f"Final matched keyword: {matched_word}") else: logging.info("No keyword match found.") except Exception as e: logging.error(f"Processing error: {e}") return jsonify({"error": "Error processing the audio file"}), 500 return jsonify({ "recognized_text": recognized_text, "matched_word": matched_word if matched_word else "No match found" }) # ------------------ Run Server ------------------ if __name__ == "__main__": port = int(os.environ.get("PORT", 5000)) logging.info(f"Server running on port {port}") app.run(host="0.0.0.0", port=port)
××§××× ×©××××Ŗ× ×ר×ר...
××× ××§×Ø× ×× ×× ×©×× ×××× ×©×פ×××Ŗ ××××¢ ש×ש ××פצ×× ×××, ×××× ×× ×”××Ŗ!
××צ×××! -
@y6714453 ××Ŗ× ×
ļø
××××× ××××ר ××¢×ר××Ŗ ā ××× ×, ×××××Ŗ×, ×××××§!!:
×× ×¦×Ø×× ××¤×Ŗ× API !
××תר × ×××, צר×× ×פת×, ××× ×ש ××¤×Ŗ× ×©××”×Ŗ××× ××¢××× (××× ×××§×ר ×××¢×Ŗ× ××××× ×ר××, ×ש ××× ×××× ×פ××רפ××§×”), ×××× ×××××¢ ×הפר××
-
@MGM-IVR ×××× ×××Ŗ ××××× × ××××Ŗ× ×©×× ×¦×Ø×× ×××× ××” ××× ××Ŗ
-
@y6714453
××× ××§×××× ××Ŗ ×××§××× ××§×××Ŗ ×שרת? -
@××¢××ר-××××× ××ר××Ŗ ×§××ׄ..
-
@CUBASE
×× ×× ×Ŗ×××× ×§×¦×Ŗ
××§×× ×××××Ŗ ××ש×× ××Ŗ ×©× ×××§××× ××× ×××ר×× ××ש××× ××××× ××× ××§×× ×××Ø× -
××× ××§×××× ××Ŗ ×××§××× ××§×××Ŗ ×שרת?
ש××××Ŗ API ×¢× ×××ר××Ŗ ×ש×× ××× ××:
type=api api_link=https:// api_000=stockname,no,record,/9,,no,yes
-
@y6714453
×ש×× ××צ×ר ×××Ŗ× ×§×©×Ø ×× ×ש×! -
@פ×××” ××Ŗ× ×
ļø
××××× ××××ר ××¢×ר××Ŗ ā ××× ×, ×××××Ŗ×, ×××××§!!:
@y6714453
×ש×× ××צ×ר ×××Ŗ× ×§×©×Ø ×× ×ש×! -
-
×ש×× ××¢×ר×. עש××Ŗ× ××Ŗ ××§×× ××× ××Ø× ×ר.
×× ×××ר ×××××Ŗ ××××ר ×ש×××× ×©× ×××××× ××××ר? (×× ×§×× ×©×××ר ×ש××× ××× ××Ŗ ××רת ×××××ר ×©× ××××××import os import tempfile import logging import requests from flask import Flask, request, jsonify from pydub import AudioSegment import speech_recognition as sr # ------------------ Logging ------------------ logging.basicConfig( level=logging.INFO, format="%(asctime)s | %(levelname)s | %(message)s", datefmt="%H:%M:%S" ) app = Flask(__name__) # ------------------ Telegram Config ------------------ TELEGRAM_BOT_TOKEN = "***" TELEGRAM_CHAT_ID = "***" # ------------------ Helper Functions ------------------ def add_silence(input_path: str) -> AudioSegment: audio = AudioSegment.from_file(input_path, format="wav") silence = AudioSegment.silent(duration=1000) return silence + audio + silence def recognize_speech(audio_segment: AudioSegment) -> str: recognizer = sr.Recognizer() try: with tempfile.NamedTemporaryFile(suffix=".wav", delete=True) as temp_wav: audio_segment.export(temp_wav.name, format="wav") with sr.AudioFile(temp_wav.name) as source: data = recognizer.record(source) text = recognizer.recognize_google(data, language="he-IL") logging.info(f"Recognized text: {text}") return text except sr.UnknownValueError: return "" except Exception as e: logging.error(f"Speech recognition error: {e}") return "" def send_to_telegram(text: str, file_url: str): message = f"šļø ××××¢× ×××©× ×××ער××Ŗ:\n\n{text}\n\nš ×§××ׄ ×××§×××:\n{file_url}" url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage" requests.post(url, data={"chat_id": TELEGRAM_CHAT_ID, "text": message}) # ------------------ API Endpoint ------------------ @app.route("/upload_audio", methods=["GET"]) def upload_audio(): file_url = request.args.get("file_url") if not file_url: return jsonify({"error": "Missing 'file_url' parameter"}), 400 logging.info(f"Downloading audio from: {file_url}") try: response = requests.get(file_url, timeout=15) if response.status_code != 200: return jsonify({"error": "Failed to download audio file"}), 400 with tempfile.NamedTemporaryFile(suffix=".wav", delete=True) as temp_input: temp_input.write(response.content) temp_input.flush() processed_audio = add_silence(temp_input.name) recognized_text = recognize_speech(processed_audio) if recognized_text: send_to_telegram(recognized_text, file_url) return jsonify({"recognized_text": recognized_text}) else: send_to_telegram(" ×× ×××× ××××ר.", file_url) return jsonify({"recognized_text": ""}) except Exception as e: logging.error(f"Error: {e}") return jsonify({"error": str(e)}), 500 # ------------------ Run ------------------ if __name__ == "__main__": port = int(os.environ.get("PORT", 5000)) app.run(host="0.0.0.0", port=port)
-
@××¢×§×-1
×ש×××× ××Ŗ× ×¦×Ø×× ×××××ר ש×ש×× ××Ŗ ×××§××× ×שרת
××× ×Ŗ×××ר ××type=api api_link=ש×× ××Ŗ ×××× ×§ ×©× ×שרת api_000=stockname,no,record,/9,,no,yes ××××× ×ש×××× ×× ××Ŗ××§ (××××ׄ) api_hangup_send=no ××¢×ר ××”××× api_end_goto=/ש×× ××Ŗ ×× ×Ŗ×× ×××¢×ר
××× ×Ŗ×©×× ×××¢×××Ŗ ×§××ׄ ש××¢ ××©× 000 ×ש×××× ×©×××ר ×ש×× ××× "×× × ××§×× ××Ŗ ××××¢×Ŗ×, ×××”××× ×קש ×”×××××Ŗ"
-
@y6714453 ×Ŗ×××!
-
@××¢×§×-1
×ש××× ××× ××¢ ש×××× - ×Ŗ××××£ ××××ר××Ŗ ×ש×××× ×××§××api_000=stockname,no,record,/9,,no,yes
××Ŗ ××:
api_000=file_url,no,record,/9,,no,yes
×××× ×©××§×× - ××× ××פש פר××ר ×ש×
file_url
××¤× ×ש××Ø× ××××Ŗ ××§××file_url = request.args.get("file_url")
-
@××¢×§×-1 ×צ×××Ŗ ×××Ŗ×§×× ffmpeg ×¢× Render ××× ×©××× ×§×Ø×” ××Ŗ×××× ××× ×××??
-
@CUBASE ××Ŗ× ×
ļø
××××× ××××ר ××¢×ר××Ŗ ā ××× ×, ×××××Ŗ×, ×××××§!!:
ffmpeg
×× ×§×Ø×”
-
@y6714453 ×ש ×× ××××Ŗ ש×××××Ŗ ×××× × ×Ŗ×× ×©×××
×× ×× ×9 ×ש××Ø× ××××Ŗ?
api_000=file_url,no,record,/9,,no,yes -
@××¢×§×-1
×××¤× ×××§××× × ×©×רת
צ×××× ×××ש××× ×©× ××××××:××¢×Ø× ×ר×××¢× (××§×××)
××¢×Ø× ×× × ××Ŗ× ×××××ר ×××× ×Ŗ×ש×ר ×××§××× ××ער××Ŗ
×ר×רת ×××× ×× × ×©×ר ××Ŗ××§××× ×©××××רת ×-api_dir
× ××Ŗ× ×××××ר ×××§×× ×©×× ×
××××××
/8
(×”×ש ש××× ×)
×××§×Ø× ××× ×××§××× ×Ŗ×ש×ר ×ש×××× 8
×ער×: ×××× ×ש××/
×××Ŗ×××. ××”×ר ×ש××/
××”××£ -
@CUBASE ××Ŗ× ×
ļø
××××× ××××ר ××¢×ר××Ŗ ā ××× ×, ×××××Ŗ×, ×××××§!!:
@××¢×§×-1 ×צ×××Ŗ ×××Ŗ×§×× ffmpeg ×¢× Render ××× ×©××× ×§×Ø×” ××Ŗ×××× ××× ×××??
××× ×©×קר××”? ×× × ××©× ×”×¤×Ø×× ××××, ×× ×× × ×Ŗ×××Ŗ??
-
@y6714453 ××××Ø× ×××××Ŗ רש××× ×©× ×ש×××× ×©×× ×××§××× ×Ŗ×ש×ר ×× ×©××× × ××§× ××Ŗ ×××§××× ×××ר×? ××× ×× ×××× ××××ר ש×××× ×©×× ×××¦× ××Ŗ ×× ×Ŗ×× 6&file_url=/9/000.wav
-
@××¢×§×-1 ××Ŗ× ×
ļø
××××× ××××ר ××¢×ר××Ŗ ā ××× ×, ×××××Ŗ×, ×××××§!!:
@y6714453 ××××Ø× ×××××Ŗ רש××× ×©× ×ש×××× ×©×× ×××§××× ×Ŗ×ש×ר ×× ×©××× × ××§× ××Ŗ ×××§××× ×××ר×? ××× ×× ×××× ××××ר ש×××× ×©×× ×××¦× ××Ŗ ×× ×Ŗ×× 6&file_url=/9/000.wav
×ש×××× ×©×× ×××§××× ×Ŗ×ש×ר - ××× ×§×©×Ø ××× ×©×שרת ××§××, (××Ŗ× ×××× ×× ××ש××ר ××Ŗ ××¢×Ø× ×Ø××§ ××× ×××§××× ×Ŗ×ש×ר ××Ŗ××§×××
api_dir
).
×× ×× ××”××× ×ש××××.×Ŗ×¢×× ×¤× ××Ŗ ×ש×××× ×©××Ŗ× ××§××