File size: 5,623 Bytes
83f9601
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# 🚀 Opções para Testar no GCP

Você tem **4 opções** para testar o sistema no GCP. Escolha a mais conveniente:

---

## ⭐ OPÇÃO 1: Google Cloud Shell (RECOMENDADO - GRÁTIS!)

**Vantagens**:
-**100% Grátis** (Cloud Shell é grátis)
- ✅ Já tem gcloud instalado
- ✅ Não precisa instalar nada local
- ✅ Mais rápido e fácil

**Como fazer**:

1. Abra o Cloud Shell: https://shell.cloud.google.com/

2. No terminal do Cloud Shell, rode:

```bash
# Download do script
curl -O https://huggingface.co/marcosremar2/ensemble-tts-annotation/raw/main/scripts/test/launch_gcp_spot.sh

# Tornar executável
chmod +x launch_gcp_spot.sh

# Rodar
./launch_gcp_spot.sh
```

3. O script vai:
   - ✅ Buscar instância mais barata (~e2-medium)
   - ✅ Criar instância spot
   - ✅ Instalar dependências
   - ✅ Rodar teste
   - ✅ Mostrar resultados

4. Quando terminar, delete a instância:
```bash
gcloud compute instances delete ensemble-test-XXX --zone=us-central1-a --quiet
```

**Custo**: $0 (Cloud Shell) + ~$0.003 (instância por 20min) = **~$0.003 total**

---

## 🌐 OPÇÃO 2: Console Web (Interface Gráfica)

**Vantagens**:
- ✅ Visual e intuitivo
- ✅ Não precisa de terminal
- ✅ Fácil para iniciantes

**Como fazer**:

1. Acesse: https://console.cloud.google.com/compute/instances

2. Click **CREATE INSTANCE**

3. Configure:
   - Nome: `ensemble-test`
   - Região: `us-central1 (Iowa)`
   - Zona: `us-central1-a`
   - Tipo: `e2-medium` (2 vCPU, 4GB RAM)
   -**Marcar**: Spot (Preemptible)
   - Disco: Ubuntu 22.04 LTS, 20GB

4. Em **Management → Automation**, cole este script:

```bash
#!/bin/bash
apt-get update && apt-get install -y python3-pip git
pip3 install --upgrade pip
cd /home && git clone https://huggingface.co/marcosremar2/ensemble-tts-annotation
cd ensemble-tts-annotation
pip3 install torch --index-url https://download.pytorch.org/whl/cpu
pip3 install transformers datasets librosa soundfile numpy pandas tqdm scikit-learn
python3 test_local.py > /tmp/test-results.log 2>&1
echo "✅ Done. Results: cat /tmp/test-results.log"
```

5. Click **CREATE**

6. Após 2 minutos, click **SSH** e rode:
```bash
cat /tmp/test-results.log
```

7. **Delete** a instância quando terminar!

**Custo**: ~$0.003 (20 minutos)

---

## 💻 OPÇÃO 3: Instalar gcloud CLI Localmente

**Vantagens**:
- ✅ Controle total do terminal
- ✅ Automação completa
- ✅ Reutilizável para outros projetos

**Como fazer**:

1. Instalar gcloud:

```bash
# macOS
brew install google-cloud-sdk

# Ou download direto
curl https://sdk.cloud.google.com | bash
exec -l $SHELL
```

2. Configurar:
```bash
gcloud init
```

3. Rodar o script:
```bash
cd ensemble-tts-annotation
bash scripts/test/launch_gcp_spot.sh
```

**Custo**: ~$0.003

---

## 🐍 OPÇÃO 4: Script Python (Sem gcloud CLI)

**Vantagens**:
- ✅ Não precisa de gcloud CLI
- ✅ Usa API do GCP diretamente
- ✅ Programático

**Como fazer**:

1. Instalar biblioteca:
```bash
pip install google-cloud-compute google-auth
```

2. Autenticar:

**Opção A** - Application Default Credentials (se tem gcloud):
```bash
gcloud auth application-default login
```

**Opção B** - Service Account (sem gcloud):
1. Console: https://console.cloud.google.com/iam-admin/serviceaccounts
2. Create Service Account
3. Grant role: **Compute Instance Admin**
4. Create key → Download JSON
5. Set environment:
```bash
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/key.json"
export GCP_PROJECT_ID="seu-projeto-id"
```

3. Rodar script:
```bash
python scripts/test/launch_gcp_python.py
```

**Custo**: ~$0.003

---

## 📊 Comparação das Opções

| Opção | Setup | Facilidade | Custo | Tempo |
|-------|-------|------------|-------|-------|
| **1. Cloud Shell** | 0 min | ⭐⭐⭐⭐⭐ | $0.003 | 5 min |
| **2. Console Web** | 0 min | ⭐⭐⭐⭐ | $0.003 | 10 min |
| **3. gcloud CLI** | 5 min | ⭐⭐⭐ | $0.003 | 5 min |
| **4. Python API** | 10 min | ⭐⭐ | $0.003 | 5 min |

---

## 🎯 Minha Recomendação

**Use a OPÇÃO 1 (Cloud Shell)**:

1. É **grátis** (Cloud Shell não cobra)
2. É **mais rápido** (já tem tudo instalado)
3. É **mais fácil** (só copiar e colar)

```bash
# Literalmente 3 comandos:
curl -O https://huggingface.co/marcosremar2/ensemble-tts-annotation/raw/main/scripts/test/launch_gcp_spot.sh
chmod +x launch_gcp_spot.sh
./launch_gcp_spot.sh
```

---

## ⚠️ IMPORTANTE: Deletar Instância

**Não esqueça de deletar** quando terminar!

```bash
# Via gcloud
gcloud compute instances delete ensemble-test-XXX --zone=us-central1-a --quiet

# Via console
https://console.cloud.google.com/compute/instances
→ Selecionar instância → DELETE
```

Se esquecer rodando, custo máximo:
- $0.01/hora × 24 horas = **$0.24/dia**
- GCP vai enviar alerta de cobrança

---

## 📝 Checklist

Antes de começar, certifique-se:

- [ ] Tem conta GCP (gratuita serve: https://cloud.google.com/free)
- [ ] Tem projeto criado
- [ ] Compute Engine API está habilitada
- [ ] Tem créditos ou cartão configurado (custo: ~$0.003)

Se primeira vez usando GCP:
1. https://console.cloud.google.com/
2. Create new project
3. Enable Compute Engine API
4. Seguir OPÇÃO 1 (Cloud Shell)

---

## 🚀 Quick Start

**Para começar AGORA (5 minutos)**:

1. Abrir: https://shell.cloud.google.com/
2. Colar:
```bash
curl -O https://huggingface.co/marcosremar2/ensemble-tts-annotation/raw/main/scripts/test/launch_gcp_spot.sh && chmod +x launch_gcp_spot.sh && ./launch_gcp_spot.sh
```
3. Seguir instruções
4. Ver resultados
5. Deletar instância

**Pronto!** 🎉

Custo total: **menos de 1 centavo** 💰