Redmind commited on
Commit
452575b
1 Parent(s): 2acfb26

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +53 -2
app.py CHANGED
@@ -19,8 +19,59 @@ def deepgram_transcribe(audio_file):
19
  return transcription
20
 
21
  def assemblyai_transcribe(audio_file):
22
- # Replace with actual Assembly AI transcription code
23
- transcription = "This is a dummy transcription from Assembly AI API"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  return transcription
25
 
26
  # Sentiment analysis function
 
19
  return transcription
20
 
21
  def assemblyai_transcribe(audio_file):
22
+ import assemblyai as aai
23
+
24
+ # Replace with your API key
25
+ aai.settings.api_key = "96206c6070cf4157b84f4f8eb66b5903"
26
+
27
+ # URL of the file to transcribe
28
+ #FILE_URL = "https://assemblyaiusercontent.com/playground/ECw2Ncu7btO.mp3"
29
+ #FILE_URL = "C:/lakshmi/AI usecases/tamil_audio1.mp3"
30
+
31
+ # You can also transcribe a local file by passing in a file path
32
+ # FILE_URL = './path/to/file.mp3'
33
+
34
+ # You can set additional parameters for the transcription
35
+ config = aai.TranscriptionConfig(
36
+ speech_model=aai.SpeechModel.nano,
37
+
38
+ language_detection=True
39
+ )
40
+
41
+ transcriber = aai.Transcriber(config=config)
42
+ transcript = transcriber.transcribe(audio_file)
43
+
44
+ if transcript.status == aai.TranscriptStatus.error:
45
+ print(transcript.error)
46
+ else:
47
+ print(transcript.text)
48
+ # Load a pre-trained sentiment analysis model for Tamil
49
+ #test_script = "இந்த செய்தி மிகவும் சோகம் மிகுந்தது.இந்த செய்தி நன்றாக உள்ளது."
50
+ """from transformers import pipeline
51
+ sentiment_analyzer = pipeline("sentiment-analysis", model="nlptown/bert-base-multilingual-uncased-sentiment")
52
+ result = sentiment_analyzer(transcript.text)
53
+ print(result)
54
+
55
+ lines = test_script.split('.') # Split the transcript into lines
56
+ sentiment_results = []
57
+
58
+ for line in lines:
59
+ line = line.strip() # Remove leading/trailing whitespace
60
+ if line: # Only analyze non-empty lines
61
+ sentiment = sentiment_analyzer(line)
62
+ sentiment_results.append((line, sentiment))
63
+ print(sentiment_results)
64
+ # Write the Tamil text to a file
65
+ with open("tamil_text1.txt", "w", encoding="utf-8") as file:
66
+ file.write(transcript.text)
67
+
68
+ # Write the sentiment analysis results to a file
69
+
70
+ # Write the list of dictionaries in a human-readable format
71
+ with open("tamil_result.txt", 'w', encoding='utf-8') as file:
72
+ for result in sentiment_results:
73
+ file.write(f"Label: {result[0]}, Score: {result[1]}\n")
74
+ """
75
  return transcription
76
 
77
  # Sentiment analysis function