Python Kodu

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

import io

from google.cloud import speech_v1p1beta1 as speech


import nltk
from nltk.corpus import stopwords

# Google Cloud Speech-to-Text API i�in istemci olu�turma


client = speech.SpeechClient()

# Ses dosyas�n� y�kleyin ve Speech-to-Text API kullanarak metne d�n�t�r�n


with io.open('ses_dosyasi.flac', 'rb') as f:
content = f.read()

audio = speech.types.RecognitionAudio(content=content)
config = speech.types.RecognitionConfig(
encoding=speech.enums.RecognitionConfig.AudioEncoding.FLAC,
language_code='tr-TR') # Bu �rnekte T�rk�e kullan�lm�t�r. Dil kodunu
de�i�tirebilirsiniz.

response = client.recognize(config=config, audio=audio)

transcript = ""
for result in response.results:
transcript += result.alternatives[0].transcript

# Metni i�leyin ve en s�k kullan�lan kelimeleri belirleyin


tokens = nltk.word_tokenize(transcript)
tokens = [word.lower() for word in tokens if word.isalpha()]
stop_words = set(stopwords.words('turkish'))
filtered_tokens = [word for word in tokens if word not in stop_words]

fdist = nltk.FreqDist(filtered_tokens)
top_words = fdist.most_common(10)

print("En s�k kullan�lan kelimeler:")


for word, frequency in top_words:
print(f"{word}: {frequency}")

You might also like